Search code examples
c#vb.netwinformsdevexpressxtratreelist

XtraTreeList CustomDrawNodeCell not working as expected (binded with dynamic DataTable)


I have a TreeList with 3 Levels of nodes: City -> Department -> Employee. Now there are a few fields which are applicable in case when it is only City and few applicable when it is only Department or Employee. For example:

  1. When it is City then draw cells of the fields 'Same_City' and 'Postal_code_mentioned'
  2. When it is Department or Employee then draw cells of field 'Id_mentioned'. In this case above 2 cell's editors are invisible and vice-versa.

For this I handled the event CustomDrawNodeCell of the Treelist and did e.Handled=True for each respective cases.

Now the code is working fine when I have a binding list, but when I am trying to do same with dynamic DataTable then it is not working. In this case when the node 'City' is selected then all the cells of the City node and its child nodes (Department and Employee) are becoming invisible (including Id_mentioned) and as soon as I click Employee or Department and all the cells of City are becoming visible along with Id_mentioned.

In short, in this case e.Handled hides/shows cell editor of each and every cell in the TreeList and not of a specific node!

Any idea about this behavior?


Solution

  • Got the problem. I was trying to get the node with TreeList1.GetDataRecordByNode(TreeList1.FocusedNode) instead TreeList1.GetDataRecordByNode(e.Node).