Imports AxSftTreeLib70 Imports SftTreeLib70 Imports Softelvdm.OLEConvert Public Class Form1 Inherits System.Windows.Forms.Form #Region " Windows Form Designer generated code " Public Sub New() MyBase.New() 'This call is required by the Windows Form Designer. InitializeComponent() 'Add any initialization after the InitializeComponent() call End Sub 'Form overrides dispose to clean up the component list. Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean) If disposing Then If Not (components Is Nothing) Then components.Dispose() End If End If MyBase.Dispose(disposing) End Sub 'Required by the Windows Form Designer Private components As System.ComponentModel.IContainer 'NOTE: The following procedure is required by the Windows Form Designer 'It can be modified using the Windows Form Designer. 'Do not modify it using the code editor. Public WithEvents Command1 As System.Windows.Forms.Button Public WithEvents Timer1 As System.Windows.Forms.Timer Friend WithEvents imageListWorld As System.Windows.Forms.ImageList Friend WithEvents imageListBitmaps As System.Windows.Forms.ImageList Public WithEvents Label5 As System.Windows.Forms.Label Public WithEvents EditControl As System.Windows.Forms.TextBox Friend WithEvents AxSftTree1 As AxSftTreeLib70.AxSftTree Friend WithEvents SftHelperComponent1 As Softelvdm.OCXHelper.SftHelperComponent <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent() Me.components = New System.ComponentModel.Container() Dim resources As System.Resources.ResourceManager = New System.Resources.ResourceManager(GetType(Form1)) Me.Command1 = New System.Windows.Forms.Button() Me.Timer1 = New System.Windows.Forms.Timer(Me.components) Me.imageListWorld = New System.Windows.Forms.ImageList(Me.components) Me.imageListBitmaps = New System.Windows.Forms.ImageList(Me.components) Me.Label5 = New System.Windows.Forms.Label() Me.AxSftTree1 = New AxSftTreeLib70.AxSftTree() Me.EditControl = New System.Windows.Forms.TextBox() Me.SftHelperComponent1 = New Softelvdm.OCXHelper.SftHelperComponent(Me.components) CType(Me.AxSftTree1, System.ComponentModel.ISupportInitialize).BeginInit() Me.SuspendLayout() ' 'Command1 ' Me.Command1.Anchor = (System.Windows.Forms.AnchorStyles.Top Or System.Windows.Forms.AnchorStyles.Right) Me.Command1.BackColor = System.Drawing.SystemColors.Control Me.Command1.Cursor = System.Windows.Forms.Cursors.Default Me.Command1.DialogResult = System.Windows.Forms.DialogResult.Cancel Me.Command1.Font = New System.Drawing.Font("Microsoft Sans Serif", 8.25!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte)) Me.Command1.ForeColor = System.Drawing.SystemColors.ControlText Me.Command1.Location = New System.Drawing.Point(368, 8) Me.Command1.Name = "Command1" Me.Command1.RightToLeft = System.Windows.Forms.RightToLeft.No Me.Command1.Size = New System.Drawing.Size(88, 24) Me.Command1.TabIndex = 35 Me.Command1.Text = "Close" ' 'Timer1 ' Me.Timer1.Enabled = True ' 'imageListWorld ' Me.imageListWorld.ColorDepth = System.Windows.Forms.ColorDepth.Depth8Bit Me.imageListWorld.ImageSize = New System.Drawing.Size(32, 32) Me.imageListWorld.ImageStream = CType(resources.GetObject("imageListWorld.ImageStream"), System.Windows.Forms.ImageListStreamer) Me.imageListWorld.TransparentColor = System.Drawing.Color.White ' 'imageListBitmaps ' Me.imageListBitmaps.ColorDepth = System.Windows.Forms.ColorDepth.Depth8Bit Me.imageListBitmaps.ImageSize = New System.Drawing.Size(16, 16) Me.imageListBitmaps.ImageStream = CType(resources.GetObject("imageListBitmaps.ImageStream"), System.Windows.Forms.ImageListStreamer) Me.imageListBitmaps.TransparentColor = System.Drawing.Color.Blue ' 'Label5 ' Me.Label5.BackColor = System.Drawing.SystemColors.Control Me.Label5.Cursor = System.Windows.Forms.Cursors.Default Me.Label5.Font = New System.Drawing.Font("Microsoft Sans Serif", 8.25!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte)) Me.Label5.ForeColor = System.Drawing.SystemColors.ControlText Me.Label5.Location = New System.Drawing.Point(368, 112) Me.Label5.Name = "Label5" Me.Label5.RightToLeft = System.Windows.Forms.RightToLeft.No Me.Label5.Size = New System.Drawing.Size(89, 328) Me.Label5.TabIndex = 36 Me.Label5.Text = "Click on the SftTree/OCX control and hit F1 to access online help for SftTree/OCX" & _ " 6.0" Me.Label5.Visible = False ' 'AxSftTree1 ' Me.AxSftTree1.Anchor = (((System.Windows.Forms.AnchorStyles.Top Or System.Windows.Forms.AnchorStyles.Bottom) _ Or System.Windows.Forms.AnchorStyles.Left) _ Or System.Windows.Forms.AnchorStyles.Right) Me.AxSftTree1.Location = New System.Drawing.Point(8, 8) Me.AxSftTree1.Name = "AxSftTree1" Me.AxSftTree1.OcxState = CType(resources.GetObject("AxSftTree1.OcxState"), System.Windows.Forms.AxHost.State) Me.AxSftTree1.Size = New System.Drawing.Size(353, 400) Me.AxSftTree1.TabIndex = 34 ' 'EditControl ' Me.EditControl.AcceptsReturn = True Me.EditControl.AutoSize = False Me.EditControl.BackColor = System.Drawing.SystemColors.Window Me.EditControl.Cursor = System.Windows.Forms.Cursors.IBeam Me.EditControl.Enabled = False Me.EditControl.Font = New System.Drawing.Font("Microsoft Sans Serif", 8.25!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte)) Me.EditControl.ForeColor = System.Drawing.SystemColors.WindowText Me.EditControl.Location = New System.Drawing.Point(368, 40) Me.EditControl.MaxLength = 0 Me.EditControl.Name = "EditControl" Me.EditControl.RightToLeft = System.Windows.Forms.RightToLeft.No Me.EditControl.Size = New System.Drawing.Size(89, 19) Me.EditControl.TabIndex = 37 Me.EditControl.Text = "EditControl" Me.EditControl.Visible = False ' 'Form1 ' Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13) Me.CancelButton = Me.Command1 Me.ClientSize = New System.Drawing.Size(464, 414) Me.Controls.AddRange(New System.Windows.Forms.Control() {Me.EditControl, Me.Command1, Me.Label5, Me.AxSftTree1}) Me.Name = "Form1" Me.Text = "Softel vdm, Inc. - Virtual Sample" CType(Me.AxSftTree1, System.ComponentModel.ISupportInitialize).EndInit() Me.ResumeLayout(False) End Sub #End Region '--locate-marker-- 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 AxSftTreeLib70._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 AxSftTreeLib70._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 AxSftTreeLib70._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 AxSftTreeLib70._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 AxSftTreeLib70._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 AxSftTreeLib70._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 AxSftTreeLib70._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 AxSftTreeLib70._DSftTreeEvents_EditEndedEvent) Handles AxSftTree1.EditEnded Timer1.Enabled = True ' restart the spinning globe End Sub End Class