3

我是开发快递技术的新手。我在使用 devexpress XtraTreeList 时遇到问题,因为我无法获取节点“NAME”和“TEXT”属性。请任何人通过代码帮助我。

4

2 回答 2

0

也许这个例子可以帮助你:

Public Sub LoadTree()
    TreeList1.Columns.Add().Name = "DisplayColumn"

    Dim node1 = TreeList1.Nodes.Add("Father")
    node1.Tag = "Father"

    Dim node1_1 = TreeList1.Nodes.Add("Child Node")
    node1_1.Tag = "Child Node"

    Dim node1_1_1 = node1.Nodes.Add("This is a grandchild node")
    node1_1_1.Tag = "Grandchild 1"

    Dim node1_1_2 = node1.Nodes.Add("Another grandchild node")
    node1_1_2.Tag = "Grandchild 2"

End Sub

Public Sub DisplayNodeValue(ByVal tag As String)
    Dim valueToPresent = FirstTagValueInNode(TreeList1.Nodes, tag)
    MsgBox(valueToPresent.ToString)
End Sub

Public Function FirstTagValueInNode(ByVal nodes As DevExpress.XtraTreeList.Nodes.TreeListNodes, ByVal tagSearch As Object)
    For Each node As DevExpress.XtraTreeList.Nodes.TreeListNode In nodes
        If node.Tag = tagSearch Then
            Return node.GetValue(TreeList1.Columns(0))
        End If
        If node.Nodes.Count > 0 Then
            Return FirstTagValueInNode(node.Nodes, tagSearch)
        End If
    Next

    Return Nothing
End Function
于 2012-06-19T12:43:46.050 回答
0

您需要记住的一件事是每个节点都可以由多个值组成。基于显示的列数。因此,您实际想要访问的是节点的特定列,以便访问或设置节点中该列的值。

例如:

TreeListColumn columnID1 = treeList1.Columns["Budget"];
// Get a cell's value in the first root node. 
object cellValue1 = treeList1.Nodes[0][columnID1];

string columnID2 = "Budget";
// Get the display text of the focused node's cell 
string cellText = treeList1.FocusedNode.GetDisplayText(columnID2);

也请查看 devExpress文档。这很有帮助。

于 2012-06-19T12:13:01.093 回答