Search code examples
c#winformsdevexpresstreelist

Bind a record in Treelist


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.


Solution

  • 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; 
    }