SftTree/DLL 7.5 - Tree Control
SftBox/OCX 5.0 - Combo Box Control
SftButton/OCX 3.0 - Button Control
SftMask/OCX 7.0 - Masked Edit Control
SftTabs/OCX 6.5 - Tab Control (VB6 only)
SftTree/OCX 7.5 - Tree Control
SftPrintPreview/DLL 2.0 - Print Preview Control (discontinued)
SftTree/DLL 7.5 - Tree Control
SftBox/OCX 5.0 - Combo Box Control
SftButton/OCX 3.0 - Button Control
SftDirectory 3.5 - File/Folder Control (discontinued)
SftMask/OCX 7.0 - Masked Edit Control
SftOptions 1.0 - Registry/INI Control (discontinued)
SftPrintPreview/OCX 1.0 - Print Preview Control (discontinued)
SftTabs/OCX 6.5 - Tab Control (VB6 only)
SftTree/OCX 7.5 - Tree Control
SftTabs/NET 6.0 - Tab Control (discontinued)
SftTree/NET 2.0 - Tree Control
This sample illustrates using virtual mode with cell editing.
The source code is located at C:\Program Files (x86)\Softelvdm\SftTree OCX 7.5\Samples\Visual Studio - VB.NET\Virtual\Form1.vb or C:\Program Files\Softelvdm\SftTree OCX 7.5\Samples\Visual Studio - VB.NET\Virtual\Form1.vb (on 32-bit Windows versions).
Private m_PicCount As Integer = 0 ' spinning globe index
Private Sub Command1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Command1.Click
Application.Exit()
End Sub
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
m_PicCount = 0
AxSftTree1.VirtualMode = True
AxSftTree1.VirtualCount(10000000)
AxSftTree1.VirtualImageSizes(16, 16, 16, 16, 16, 16, 16, 16)
' Make columns and row headers optimal
' but do this at the end of the list, because our sample
' data is larger at the end
AxSftTree1.Items.TopIndex = AxSftTree1.Items.Count - 1
AxSftTree1.ColumnsObj.MakeOptimal()
AxSftTree1.RowHeaders.MakeOptimal()
AxSftTree1.Items.RecalcHorizontalExtent()
AxSftTree1.Items.TopIndex = 0
End Sub
Private Sub Timer1_Tick(ByVal sender As Object, ByVal e As System.EventArgs) Handles Timer1.Tick
AxSftTree1.RowColumnHeader.Image.NETImageObject = imageListWorld.Images(m_PicCount)
m_PicCount = m_PicCount + 1
If m_PicCount >= imageListWorld.Images.Count Then
m_PicCount = 0
End If
End Sub
Private Sub AxSftTree1_VirtualItem(ByVal sender As Object, ByVal e As AxSftTreeLib75._DSftTreeEvents_VirtualItemEvent) Handles AxSftTree1.VirtualItem
e.itemObject.Item.Cell(0).Text = "Item " & e.rowIndex
e.itemObject.Item.Cell(1).Text = "Cell " & e.rowIndex
e.itemObject.Item.Cell(2).Text = "A"
e.itemObject.Item.Cell(3).Text = (e.rowIndex Mod 7)
e.itemObject.Item.Cell(4).Text = "Last " & e.rowIndex
e.itemObject.Item.RowHeader.Text = "R" & e.rowIndex
e.itemObject.Item.Enabled = ((e.rowIndex Mod 2) = 0)
If e.rowIndex Mod 17 = 0 Then
e.itemObject.Item.RowHeader.Image.NETImageObject = imageListBitmaps.Images(e.rowIndex Mod 10)
End If
If e.rowIndex Mod 3 = 0 Then
e.itemObject.Item.Cell(1).ForeColor = OLECvt.ToOleColor(System.Drawing.Color.Red)
e.itemObject.Item.Cell(1).BackColor = OLECvt.ToOleColor(System.Drawing.Color.Aqua)
End If
If e.rowIndex Mod 5 = 0 Then
e.itemObject.Item.Cell(1).Font.Bold = True
End If
If e.rowIndex Mod 7 = 0 Then
e.itemObject.Item.Image.NETImageObject = imageListBitmaps.Images((e.rowIndex + 9) Mod 10)
e.itemObject.Item.LabelImage.NETImageObject = imageListBitmaps.Images((e.rowIndex + 1) Mod 10)
End If
If e.rowIndex Mod 13 = 0 Then
e.itemObject.Item.RowHeader.Image.NETImageObject = imageListBitmaps.Images((e.rowIndex + 5) Mod 10)
End If
If e.rowIndex Mod 11 = 0 Then
e.itemObject.Item.RowHeader.ImageHAlign = SftTreeHAlignConstants.halignSftTreeRight
End If
If e.rowIndex Mod 9 = 0 Then
e.itemObject.Item.Cell(1).Image.NETImageObject = imageListBitmaps.Images((e.rowIndex + 3) Mod 10)
End If
If e.rowIndex Mod 7 = 0 Then
e.itemObject.Item.Cell(0).Image.NETImageObject = imageListBitmaps.Images((e.rowIndex + 2) Mod 10)
e.itemObject.Item.Cell(0).ImageHAlign = SftTreeHAlignConstants.halignSftTreeRight
End If
End Sub
Private Sub AxSftTree1_ItemClick(ByVal sender As Object, ByVal e As AxSftTreeLib75._DSftTreeEvents_ItemClickEvent) Handles AxSftTree1.ItemClick
If e.areaType = SftTreeAreaTypeConstants.constSftTreeText Then
AxSftTree1.get_Cell(e.itemIndex, e.colIndex).Edit(0, 0)
End If
End Sub
Private Sub AxSftTree1_ItemDblClick(ByVal sender As Object, ByVal e As AxSftTreeLib75._DSftTreeEvents_ItemDblClickEvent) Handles AxSftTree1.ItemDblClick
If e.areaType = SftTreeAreaTypeConstants.constSftTreeColumnRes Then
AxSftTree1.get_Column(e.colIndex).MakeOptimal()
End If
End Sub
Private Sub AxSftTree1_EditInitializing(ByVal sender As Object, ByVal e As AxSftTreeLib75._DSftTreeEvents_EditInitializingEvent) Handles AxSftTree1.EditInitializing
Timer1.Enabled = False ' stop the spinning globe
' LeftPix/TopPix/WidthPix/HeightPix describes the current cell area
' we need to return the position and size needed for editing.
' In this example, we use the height of the control on the form
' and center it over the cell.
e.topPix = e.topPix + (e.heightPix - EditControl.Height) / 2
e.heightPix = EditControl.Height
' Set the text in the control used for cell editing and
' set other control-specific properties
EditControl.Width = 200
EditControl.Text = AxSftTree1.get_Cell(e.editIndex, e.editCol).Text
EditControl.SelectionStart = 0
EditControl.SelectionLength = 999
' Return the control's window handle
e.window = EditControl.Handle.ToInt32()
e.vData = EditControl
' Define navigation keys
' VK_TAB
AxSftTree1.CellEditIntercept(9, SftTreeCellEditInterceptStyleConstants.cellEditInterceptSftTreeChar Or SftTreeCellEditInterceptStyleConstants.cellEditInterceptSftTreeControlChar Or SftTreeCellEditInterceptStyleConstants.cellEditInterceptSftTreeShiftChar)
' VK_RETURN
AxSftTree1.CellEditIntercept(13, SftTreeCellEditInterceptStyleConstants.cellEditInterceptSftTreeChar Or SftTreeCellEditInterceptStyleConstants.cellEditInterceptSftTreeControlChar Or SftTreeCellEditInterceptStyleConstants.cellEditInterceptSftTreeShiftChar)
' VK_HOME
AxSftTree1.CellEditIntercept(36, SftTreeCellEditInterceptStyleConstants.cellEditInterceptSftTreeControlChar)
' VK_END
AxSftTree1.CellEditIntercept(35, SftTreeCellEditInterceptStyleConstants.cellEditInterceptSftTreeControlChar)
' VK_UP
AxSftTree1.CellEditIntercept(38, SftTreeCellEditInterceptStyleConstants.cellEditInterceptSftTreeChar Or SftTreeCellEditInterceptStyleConstants.cellEditInterceptSftTreeControlChar Or SftTreeCellEditInterceptStyleConstants.cellEditInterceptSftTreeShiftChar)
' VK_DOWN
AxSftTree1.CellEditIntercept(40, SftTreeCellEditInterceptStyleConstants.cellEditInterceptSftTreeChar Or SftTreeCellEditInterceptStyleConstants.cellEditInterceptSftTreeControlChar Or SftTreeCellEditInterceptStyleConstants.cellEditInterceptSftTreeShiftChar)
End Sub
Private Sub AxSftTree1_EditNavigating(ByVal sender As Object, ByVal e As AxSftTreeLib75._DSftTreeEvents_EditNavigatingEvent) Handles AxSftTree1.EditNavigating
' Process key pressed
AxSftTree1.EditNavigate(e.key, e.shift)
End Sub
Private Sub AxSftTree1_EditValidate(ByVal sender As Object, ByVal e As AxSftTreeLib75._DSftTreeEvents_EditValidateEvent) Handles AxSftTree1.EditValidate
' Validate the new cell contents
If EditControl.Text <> AxSftTree1.get_Cell(e.editIndex, e.editCol).Text Then
MessageBox.Show("This example doesn't preserve the changes you make, because the sample data is randomly generated.")
End If
End Sub
Private Sub AxSftTree1_EditEnding(ByVal sender As Object, ByVal e As AxSftTreeLib75._DSftTreeEvents_EditEndingEvent) Handles AxSftTree1.EditEnding
Dim ctrl As Control = e.vData
ctrl.Visible = False
ctrl.Enabled = False
End Sub
Private Sub AxSftTree1_EditEnded(ByVal sender As Object, ByVal e As AxSftTreeLib75._DSftTreeEvents_EditEndedEvent) Handles AxSftTree1.EditEnded
Timer1.Enabled = True ' restart the spinning globe
End Sub
End Class