We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

Get value of nodes after checking

Hello,

I am using a TreeViewAdv control with checkboxes. When I fill the TreeView, I set the "ValueMember" property.

After checking a node, it calls the "AfterCheck" method and I can get the "CheckedNodes" collection.

However I am not able to get the values of the nodes, which are checked. I am only able to get the "Text" oder "Name" properties.

Can you please help me and tell me, how to get the values of the nodes, which are checked, or the value of the node which gets checked in the "AfterCheck" event?

Thank you very much.
Michael

4 Replies

DV Duraimurugan Vedagiri Syncfusion Team May 7, 2020 06:06 PM UTC

Hi Michael,

Thanks for using syncfusion products.

We are analyzing to achieve your reported requirement and let you know the further details on May 11th , 2020.

We appreciate your patience until then.

Regards,
Durai



DV Duraimurugan Vedagiri Syncfusion Team May 11, 2020 01:15 PM UTC

Hi Michael,

Thanks for your patience.

You can achieve the reported requirement "How to get a ValueMember for CheckedNodes Collection in TreeViewAdv.AfterCheck event handler" by getting the internal property "Value" of TreeNodeAdv using reflection concepts. Please refer the below code snippet for your reference.

Code Snippet
private void TreeViewAdv1_AfterCheck(object sender, TreeNodeAdvEventArgs e) 
{ 
    foreach (TreeNodeAdv treeNodeAdv in (sender as TreeViewAdv).CheckedNodes) 
    { 
        System.Reflection.PropertyInfo property = treeNodeAdv.GetType().GetProperty("Value", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.Static); 
        string valueMemberValue = property.GetValue(treeNodeAdv) as string; 
    } 
} 

Regards,
Durai



MW Michael Witzik May 18, 2020 08:21 AM UTC

Hello Durai,

thank you, your solution worked perfect!

Regards,
Michael


DV Duraimurugan Vedagiri Syncfusion Team May 18, 2020 02:11 PM UTC

Hi Michael,

Thanks for your update.

We are pleased to hear that the reported requirement is achieved at your end. Please get back to us if you need any other assistance.

Regards,
Durai

Loader.
Up arrow icon