-
Notifications
You must be signed in to change notification settings - Fork 0
/
Form1.vb
57 lines (50 loc) · 2.44 KB
/
Form1.vb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
Imports Microsoft.VisualBasic
Imports System
Imports System.Collections.Generic
Imports System.ComponentModel
Imports System.Data
Imports System.Drawing
Imports System.Text
Imports System.Windows.Forms
Imports DevExpress.XtraTreeList
Imports DevExpress.XtraTreeList.Nodes
Namespace NodeContextMenu
Partial Public Class Form1
Inherits Form
Public Sub New()
InitializeComponent()
InitTreeList()
End Sub
Private Sub InitTreeList()
Dim TempXViews As DevExpress.XtraTreeList.Design.XViews = New DevExpress.XtraTreeList.Design.XViews(treeList1)
For i As Integer = 1 To treeList1.Columns.Count - 1
treeList1.Columns(i).Visible = False
Next i
End Sub
Private Sub bbEdit_ItemClick(ByVal sender As Object, ByVal e As EventArgs)
treeList1.OptionsBehavior.Editable = Not treeList1.OptionsBehavior.Editable
treeList1.ShowEditor()
End Sub
Private Sub bbAddChild_ItemClick(ByVal sender As Object, ByVal e As EventArgs)
Dim newNode As TreeListNode = treeList1.AppendNode(Nothing, treeList1.FocusedNode)
newNode.SetValue(0, "New Node")
treeList1.FocusedNode = newNode
treeList1.OptionsBehavior.Editable = Not treeList1.OptionsBehavior.Editable
treeList1.ShowEditor()
End Sub
Private Sub bbDelete_ItemClick(ByVal sender As Object, ByVal e As EventArgs)
treeList1.DeleteNode(treeList1.FocusedNode)
End Sub
Private Sub treeList1_HiddenEditor(ByVal sender As Object, ByVal e As System.EventArgs) Handles treeList1.HiddenEditor
treeList1.OptionsBehavior.Editable = False
End Sub
Private Sub treeList1_PopupMenuShowing(ByVal sender As System.Object, ByVal e As DevExpress.XtraTreeList.PopupMenuShowingEventArgs) Handles treeList1.PopupMenuShowing
If TypeOf e.Menu Is DevExpress.XtraTreeList.Menu.TreeListNodeMenu Then
treeList1.FocusedNode = (CType(e.Menu, DevExpress.XtraTreeList.Menu.TreeListNodeMenu)).Node
e.Menu.Items.Add(New DevExpress.Utils.Menu.DXMenuItem("Edit", AddressOf bbEdit_ItemClick))
e.Menu.Items.Add(New DevExpress.Utils.Menu.DXMenuItem("Add child", AddressOf bbAddChild_ItemClick))
e.Menu.Items.Add(New DevExpress.Utils.Menu.DXMenuItem("Delete", AddressOf bbDelete_ItemClick))
End If
End Sub
End Class
End Namespace