Imports System.Reflection Imports Softelvdm.SftTreeNET Public Class Form1 Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load SftTreeList.ItemCollection.Clear() SftTree1.Columns.MakeOptimal(0, False) SftTree1.RowHeaders.MakeOptimal(0, False) SftTree1.Splitter.MakeOptimal() SftTree1.RecalcHorizontalExtent() End Sub Private strLastEvent As String = "" Private fLastEventDup As Boolean = False ' This is a small helper routine to show all properties and fields of an object Private Sub DumpValues(ByVal title As String, ByVal o As Object) Dim s As String = "" If strLastEvent = title Then If Not fLastEventDup Then s = "Additional " + title + " events ... now suppressed" fLastEventDup = True Else Return End If Else strLastEvent = title fLastEventDup = False Dim api() As PropertyInfo = o.GetType().GetProperties() For Each pi As PropertyInfo In api Dim val As Object = pi.GetValue(o, New Object() {}) If val Is Nothing Then s += pi.Name + "=Nothing " Else s += pi.Name + "=" + val.ToString() + " " End If Next Dim afi() As FieldInfo = o.GetType().GetFields() For Each fi As FieldInfo In afi Dim val As Object = fi.GetValue(o) If val Is Nothing Then s += fi.Name + "=Nothing " Else s += fi.Name + "=" + val.ToString() + " " End If Next End If Dim item As ItemClass = SftTreeList.ItemCollection.Add(New String() {title, s}) item.Selected = True SftTreeList.Columns.MakeOptimal(50, True) SftTreeList.RecalcHorizontalExtent() End Sub Private Sub SftTree1_ColumnReordered(ByVal sender As System.Object, ByVal e As Softelvdm.SftTreeNET.ColumnReorderedEventArgs) Handles SftTree1.ColumnReordered DumpValues("ColumnReordered", e) End Sub Private Sub SftTree1_ColumnResized(ByVal sender As System.Object, ByVal e As Softelvdm.SftTreeNET.ColumnResizedEventArgs) Handles SftTree1.ColumnResized DumpValues("ColumnResized", e) End Sub Private Sub SftTree1_DoubleClick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SftTree1.DoubleClick DumpValues("DoubleClick", e) End Sub Private Sub SftTree1_DragDetected(ByVal sender As System.Object, ByVal e As Softelvdm.SftTreeNET.DragDetectedEventArgs) Handles SftTree1.DragDetected DumpValues("DragDetected", e) If e.Item.UsageLocation <> UsageLocationEnum.items Then Return ' ignore header/footer dragging End If e.Handled = True SftTree1.DoDragDrop("In this example, we are dragging a simple text string", DragDropEffects.Copy) End Sub Private Sub SftTree1_DragDrop(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DragEventArgs) Handles SftTree1.DragDrop DumpValues("DragDrop", e) End Sub Private Sub SftTree1_DragEnter(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DragEventArgs) Handles SftTree1.DragEnter DumpValues("DragEnter", e) e.Effect = DragDropEffects.Copy ' accept anything End Sub Private Sub SftTree1_DragLeave(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SftTree1.DragLeave DumpValues("DragLeave", e) End Sub Private Sub SftTree1_DragOver(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DragEventArgs) Handles SftTree1.DragOver DumpValues("DragOver", e) e.Effect = DragDropEffects.Copy ' accept anything End Sub Private Sub SftTree1_EditAllowed(ByVal sender As System.Object, ByVal e As Softelvdm.SftTreeNET.EditAllowedEventArgs) Handles SftTree1.EditAllowed DumpValues("EditAllowed", e) If e.Cell.ColumnIndex = 2 Then ' only edit cells in column 2 e.Allowed = True Else e.Allowed = False End If End Sub Private Sub SftTree1_EditClickOutside(ByVal sender As System.Object, ByVal e As Softelvdm.SftTreeNET.EditClickOutsideEventArgs) Handles SftTree1.EditClickOutside DumpValues("EditClickOutside", e) End Sub Private Sub SftTree1_EditEnded(ByVal sender As System.Object, ByVal e As Softelvdm.SftTreeNET.EditEndedEventArgs) Handles SftTree1.EditEnded DumpValues("EditEnded", e) ' save the new cell text if necessary If e.SaveValue Then e.Cell.Text = TextBox1.Text End If ' hide the text box and make the form the control's parent TextBox1.Visible = False TextBox1.Enabled = False TextBox1.Parent = SftTree1.Parent End Sub Private Sub SftTree1_EditSetup(ByVal sender As System.Object, ByVal e As Softelvdm.SftTreeNET.EditSetupEventArgs) Handles SftTree1.EditSetup DumpValues("EditSetup", e) TextBox1.Parent = SftTree1 ' make the tree control the parent window TextBox1.Text = e.Cell.Text Dim h As Integer = TextBox1.Height Dim r As Rectangle = e.rCell ' limit the control to the right pane - all cell editing takes place in right pane r.Intersect(SftTree1.Splitter.Right.ItemsArea) Dim vOffs As Integer = (r.Size.Height - TextBox1.Height) / 2 TextBox1.Location = New Point(r.Location.X, r.Location.Y + vOffs) TextBox1.Width = r.Width ' make it visible and enable it TextBox1.Enabled = True TextBox1.Visible = True ' off we go! TextBox1.BringToFront() TextBox1.Focus() e.EditControl = TextBox1 End Sub Private Sub SftTree1_EditValidate(ByVal sender As System.Object, ByVal e As Softelvdm.SftTreeNET.EditValidateEventArgs) Handles SftTree1.EditValidate DumpValues("EditValidate", e) End Sub Private Sub SftTree1_Enter(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SftTree1.Enter DumpValues("Enter", e) End Sub Private Sub SftTree1_FocusObjectChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SftTree1.FocusObjectChanged DumpValues("FocusObjectChanged", e) End Sub Private Sub SftTree1_FooterClicked(ByVal sender As System.Object, ByVal e As Softelvdm.SftTreeNET.FooterClickedEventArgs) Handles SftTree1.FooterClicked DumpValues("FooterClicked", e) End Sub Private Sub SftTree1_FooterDoubleClicked(ByVal sender As System.Object, ByVal e As Softelvdm.SftTreeNET.FooterClickedEventArgs) Handles SftTree1.FooterDoubleClicked DumpValues("FooterDoubleClicked", e) End Sub Private Sub SftTree1_FooterHeightChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SftTree1.FooterHeightChanged DumpValues("FooterHeightChanged", e) End Sub Private Sub SftTree1_GiveFeedback(ByVal sender As System.Object, ByVal e As System.Windows.Forms.GiveFeedbackEventArgs) Handles SftTree1.GiveFeedback DumpValues("GiveFeedback", e) End Sub Private Sub SftTree1_HeaderClicked(ByVal sender As System.Object, ByVal e As Softelvdm.SftTreeNET.HeaderClickedEventArgs) Handles SftTree1.HeaderClicked DumpValues("HeaderClicked", e) End Sub Private Sub SftTree1_HeaderDoubleClicked(ByVal sender As System.Object, ByVal e As Softelvdm.SftTreeNET.HeaderClickedEventArgs) Handles SftTree1.HeaderDoubleClicked DumpValues("HeaderDoubleClicked", e) End Sub Private Sub SftTree1_HeaderHeightChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SftTree1.HeaderHeightChanged DumpValues("HeaderHeightChanged", e) End Sub Private Sub SftTree1_HorizontalOffsetChanged(ByVal sender As System.Object, ByVal e As Softelvdm.SftTreeNET.HorizontalOffsetChangedEventArgs) Handles SftTree1.HorizontalOffsetChanged DumpValues("HorizontalOffsetChanged ", e) End Sub Private Sub SftTree1_ItemClick(ByVal sender As System.Object, ByVal e As Softelvdm.SftTreeNET.ItemClickEventArgs) Handles SftTree1.ItemClick DumpValues("ItemClick", e) If Not e.Item Is Nothing And Not e.Cell Is Nothing And e.Item.UsageLocation = UsageLocationEnum.items And e.Cell.ColumnIndex = 2 Then e.Cell.Edit() ' Start cell editing End If End Sub Private Sub SftTree1_ItemCollapsed(ByVal sender As System.Object, ByVal e As Softelvdm.SftTreeNET.ItemCollapsedEventArgs) Handles SftTree1.ItemCollapsed DumpValues("ItemCollapsed", e) End Sub Private Sub SftTree1_ItemDoubleClick(ByVal sender As System.Object, ByVal e As Softelvdm.SftTreeNET.ItemClickEventArgs) Handles SftTree1.ItemDoubleClick DumpValues("ItemDoubleClick", e) End Sub Private Sub SftTree1_ItemExpanded(ByVal sender As System.Object, ByVal e As Softelvdm.SftTreeNET.ItemExpandedEventArgs) Handles SftTree1.ItemExpanded DumpValues("ItemExpanded", e) End Sub Private Sub SftTree1_ItemRemoved(ByVal sender As System.Object, ByVal e As Softelvdm.SftTreeNET.ItemRemovedEventArgs) Handles SftTree1.ItemRemoved DumpValues("ItemRemoved", e) End Sub Private Sub SftTree1_KeyDown(ByVal sender As System.Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles SftTree1.KeyDown DumpValues("KeyDown", e) End Sub Private Sub SftTree1_KeyPress(ByVal sender As System.Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles SftTree1.KeyPress DumpValues("KeyPress", e) End Sub Private Sub SftTree1_KeyUp(ByVal sender As System.Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles SftTree1.KeyUp DumpValues("KeyUp", e) End Sub Private Sub SftTree1_Leave(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SftTree1.Leave DumpValues("Leave", e) End Sub Private Sub SftTree1_MouseClick(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles SftTree1.MouseClick DumpValues("MouseClick", e) End Sub Private Sub SftTree1_MouseDoubleClick(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles SftTree1.MouseDoubleClick DumpValues("MouseDoubleClick", e) End Sub Private Sub SftTree1_MouseDown(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles SftTree1.MouseDown DumpValues("MouseDown", e) End Sub Private Sub SftTree1_MouseEnter(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SftTree1.MouseEnter DumpValues("MouseEnter", e) End Sub Private Sub SftTree1_MouseHover(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SftTree1.MouseHover DumpValues("MouseHover", e) End Sub Private Sub SftTree1_MouseLeave(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SftTree1.MouseLeave DumpValues("MouseLeave", e) End Sub Private Sub SftTree1_MouseMove(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles SftTree1.MouseMove DumpValues("MouseMove", e) End Sub Private Sub SftTree1_MouseMoveHoverTimer(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SftTree1.MouseMoveHoverTimer DumpValues("MouseMoveHoverTimer", e) End Sub Private Sub SftTree1_MouseMoveTimer(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SftTree1.MouseMoveTimer DumpValues("MouseMoveTimer", e) End Sub Private Sub SftTree1_MouseUp(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles SftTree1.MouseUp DumpValues("MouseUp", e) End Sub Private Sub SftTree1_PreviewKeyDown(ByVal sender As System.Object, ByVal e As System.Windows.Forms.PreviewKeyDownEventArgs) Handles SftTree1.PreviewKeyDown DumpValues("PreviewKeyDown", e) End Sub Private Sub SftTree1_QueryContinueDrag(ByVal sender As System.Object, ByVal e As System.Windows.Forms.QueryContinueDragEventArgs) Handles SftTree1.QueryContinueDrag DumpValues("QueryContinueDrag", e) End Sub Private Sub SftTree1_RadioButtonClicked(ByVal sender As System.Object, ByVal e As Softelvdm.SftTreeNET.PartEventArgs) Handles SftTree1.RadioButtonClicked DumpValues("RadioButtonClicked", e) End Sub Private Sub SftTree1_SelectionChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SftTree1.SelectionChanged DumpValues("SelectionChanged", e) End Sub Private Sub SftTree1_ShowScrollTip(ByVal sender As System.Object, ByVal e As Softelvdm.SftTreeNET.ToolTipEventArgs) Handles SftTree1.ShowScrollTip DumpValues("ShowScrollTip", e) End Sub Private Sub SftTree1_ShowToolTip(ByVal sender As System.Object, ByVal e As Softelvdm.SftTreeNET.ToolTipEventArgs) Handles SftTree1.ShowToolTip DumpValues("ShowToolTip", e) If e.Usage = UsageLocationEnum.items And Not e.Cell Is Nothing And e.Cell.OwningItem.VisibleIndex = 2 And e.Cell.ColumnIndex = 3 Then e.ToolTipIcon = ToolTipIcon.Info e.ToolTipTitle = "Balloon Tooltip" e.ToolTipStyle = Softelvdm.Controls.ToolTipAppearanceEnum.Balloon e.ToolTipText = "A simple explanatory tooltip" + vbCrLf + "for just this cell" End If End Sub Private Sub SftTree1_SplitterOffsetChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SftTree1.SplitterOffsetChanged DumpValues("SplitterOffsetChanged", e) End Sub Private Sub TextBox1_KeyDown(ByVal sender As System.Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles TextBox1.KeyDown ' Handle all the cell navigation for the text box here If e.KeyCode = Keys.Up Then SftTree1.EditNavigate(EditNavigateEnum.Up) e.Handled = True ElseIf e.KeyCode = Keys.Down Then SftTree1.EditNavigate(EditNavigateEnum.Down) e.Handled = True ElseIf e.KeyCode = Keys.Left And (e.Modifiers And Keys.Control) <> 0 Then ' Ctrl+Left SftTree1.EditNavigate(EditNavigateEnum.Left) e.Handled = True ElseIf e.KeyCode = Keys.Right And (e.Modifiers And Keys.Control) <> 0 Then ' Ctrl+Right SftTree1.EditNavigate(EditNavigateEnum.Right) e.Handled = True ElseIf e.KeyCode = Keys.Home And (e.Modifiers And Keys.Control) <> 0 Then ' Ctrl+Home SftTree1.EditNavigate(EditNavigateEnum.Home) e.Handled = True ElseIf e.KeyCode = Keys.End And (e.Modifiers And Keys.Control) <> 0 Then ' Ctrl+End SftTree1.EditNavigate(EditNavigateEnum.End) e.Handled = True ElseIf e.KeyCode = Keys.Tab And (e.Modifiers And Keys.Shift) <> 0 Then ' Shift+Tab SftTree1.EditNavigate(EditNavigateEnum.Left) e.Handled = True ElseIf e.KeyCode = Keys.Tab And (e.Modifiers And Keys.Shift) = 0 Then ' Tab SftTree1.EditNavigate(EditNavigateEnum.Right) e.Handled = True ElseIf e.KeyCode = Keys.Escape Then ' ESC SftTree1.EndEdit(False) e.Handled = True ElseIf e.KeyCode = Keys.Return Then ' Return SftTree1.EndEdit(True) e.Handled = True End If End Sub ' Textboxes normally don't want Tab and Escape keys, so we enable these here Private Sub TextBox1_PreviewKeyDown(ByVal sender As System.Object, ByVal e As System.Windows.Forms.PreviewKeyDownEventArgs) Handles TextBox1.PreviewKeyDown If e.KeyCode = Keys.Tab Then e.IsInputKey = True ElseIf e.KeyCode = Keys.Escape Then e.IsInputKey = True End If End Sub End Class