Class binding possible ?

Hi,

I try to bing a list of custom class in a TreeViewAdv.

My class :

public class Category
{
public Int64 pkCategory { get; set; }
public String Name { get; set; }
public Int64 fkCategoryParent { get; set; }
}

my goal is to use Binding to Self-Referencing Data.

With many tests impossible to set the relation child vs parent.

Always all my nodes are ROOT.

Can you help me, i attached my sample test to this ticket

Regards

Cyrille


Attachment: TreeViewAdv_CF_Test_b5398f9.zip


6 Replies 1 reply marked as answer

DM Dhanasekar Mohanraj Syncfusion Team July 19, 2022 04:11 PM UTC

Hi Cyrille,

Currently, we are checking the reported issue on our end. We will check and update you on further details on July 21, 2022.

We appreciate your patience until then.

Regards,
Dhanasekar M.



DM Dhanasekar Mohanraj Syncfusion Team July 21, 2022 05:19 PM UTC

Hi Cyrille,


We have checked your requirement. By default, our TreeViewAdv does not support binding the SelfRelationRootValue to an ObservableCollection or list, its Binds only to the data Table. We have modified your sample with the DataTable.


If you need to bind the collection for TreeViewAdv you can achieve this by using the Object Relational Data which is used to bind class objects which have collections associated with other dependent class objects establishing proper relation. For more information related to binding to object-relational data, please refer to the below user guide documentation link,


UG Link: https://help.syncfusion.com/windowsforms/treeview/data-binding#binding-to-object-relational-data


Please find the modified sample and our data binding demo in the attachment and let us know if you have any concerns about this.


Regards,

Dhanasekar M.


Attachment: Samples_87bfbb58.zip

Marked as answer

FR FRANCOIS September 6, 2022 06:37 PM UTC

HI,

Thank you for the answer.


And sorry for the delay.


Regards

Cyrille



DM Dhanasekar Mohanraj Syncfusion Team September 7, 2022 01:06 PM UTC

Hi Cyrille,

If you are satisfied with our response, please mark it as an answer. Otherwise, please let us know if you have any further queries on this. We are happy to help you.

Regards,
Dhanasekar M.



FR FRANCOIS September 7, 2022 01:11 PM UTC

Hi,

It is done ;)

Regards

Cyrille



PG Peter Groft March 30, 2023 09:12 AM UTC

To bind a list of custom classes to a TreeViewAdv control, you would need to follow these general steps:


Create a list of instances of your custom class.

Set the list as the data source for the TreeViewAdv control.

Define the hierarchical structure of the TreeViewAdv control by setting the properties of the control's Nodes collection. You can use properties such as Text, Tag, and Nodes to set the display text, associated data, and child nodes for each tree node.

Configure the TreeViewAdv control's appearance and behavior as needed, using properties such as Font, ForeColor, and ShowLines.

Hope You Find This Useful,
Peter


Loader.
Up arrow icon