0

I'm facing issue in binding single row to the treelist. In my application I have a two forms. first form contains treelist it will contain list of rows.

I need a selected row from the list. Using

public object selectedRow
{
return treelist.GetDataRecordByNode(treelist.FocusedNode)
}

using this code I get the selected row.

In second Form, I'm trying to bind that row.

public void row(selectedRow)
{
treelist2.DataSource=selectedRow; //I get the row value here.
}

But data not able to shown in second treelist. what step I need to do to bind a selectedrow to second treelist.

2 Answers2

0

the DataSource should be an IEnumerable-type. try something like this (pseudo-code ahead):

public void row(selectedRow)
{
      List<yourType> list = new List<yourType>();
      list.Add(selectedRow);
      treelist2.DataSource=list; 
}
Sancho Panza
  • 670
  • 4
  • 11
0

Please go through TreeList's Data Binding section, Data Binding topic provides the complete information on binding the TreeList to data.

You can find reference to bind it with class objects here - Binding Controls to Data Created at Runtime

In your row method, you should either create a List<ClassType> or BindingList<ClassType> before assigning the data source property. A list of ClassType objects can be created and bound to a data-aware control as follows:

BindingList<ClassType> list = new BindingList<ClassType>();
treelist2.DataSource = list;

References:
DevExpress TreeList not displaying child nodes and displaying as root nodes instead
binding data to the treelist control
Binding data in DevExpress Treelist from database

Niranjan Singh
  • 18,017
  • 2
  • 42
  • 75