'DevExpress how to set and get tree node text and name at run time?
I am new in dev express technology. I am having a problem with devexpress XtraTreeList because i am unable to get node "NAME" and "TEXT" property.Please any one help me out through code.
Solution 1:[1]
One thing you need to keep in mind is that each node can be made up of multiple values. Based on the number of columns that are displayed. So, what you actually want to access is the particular column of a node in order to access or set the values for that column in the node.
For example:
TreeListColumn columnID1 = treeList1.Columns["Budget"];
// Get a cell's value in the first root node.
object cellValue1 = treeList1.Nodes[0][columnID1];
and
string columnID2 = "Budget";
// Get the display text of the focused node's cell
string cellText = treeList1.FocusedNode.GetDisplayText(columnID2);
Check out the devExpress documentation too. It's pretty helpful.
Solution 2:[2]
Maybe this example can help you:
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
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Jay |
| Solution 2 | J.Hudler |
