下面的示例展示了当内置编辑器被激活和关闭时,如何改变获得焦点的节点的状态图像。 为了对激活和关闭内置编辑器作出响应,接管了 TreeList.ShownEditor 和 TreeList.HiddenEditor 事件。 TreeList.CellValueChanged 事件被接管,从而改变节点的选中图像,以便于指明节点单元格的取值被最终用户修改。
下面的插图展示了运行结果。
C# | 复制代码 |
---|---|
using DevExpress.XtraTreeList; private void treeList1_ShownEditor(object sender, System.EventArgs e) { TreeList tlist = sender as TreeList; tlist.FocusedNode.StateImageIndex = 0; } private void treeList1_HiddenEditor(object sender, System.EventArgs e) { TreeList tlist = sender as TreeList; tlist.FocusedNode.StateImageIndex = -1; } private void treeList1_CellValueChanged(object sender, DevExpress.XtraTreeList.CellValueChangedEventArgs e) { e.Node.SelectImageIndex = 1; e.Node.ImageIndex = 1; } |
Visual Basic | 复制代码 |
---|---|
Imports DevExpress.XtraTreeList Private Sub TreeList1_ShownEditor(ByVal sender As Object, ByVal e As System.EventArgs) Handles TreeList1.ShownEditor Dim tlist As TreeList = CType(sender, TreeList) tlist.FocusedNode.StateImageIndex = 0 End Sub Private Sub TreeList1_HiddenEditor(ByVal sender As Object, ByVal e As System.EventArgs) Handles TreeList1.HiddenEditor Dim tlist As TreeList = CType(sender, TreeList) tlist.FocusedNode.StateImageIndex = -1 End Sub Private Sub TreeList1_CellValueChanged(ByVal sender As Object, ByVal e As DevExpress.XtraTreeList.CellValueChangedEventArgs) Handles TreeList1.CellValueChanged e.Node.SelectImageIndex = 1 e.Node.ImageIndex = 1 End Sub |