Winforms C1TreeView bound to dataset - cannot get record key of selected node!

Posted by: johntam on 16 April 2019, 6:07 am EST

    • Post Options:
    • Link

    Posted 16 April 2019, 6:07 am EST

    Winforms C1Tree View v4.0.20191.359

    I have a datatable bound to the TreeView and it renders properly.

    Table is

    ID

    ClassID (not displayed used for database to assemble the data)

    Level number (not displayed used for database to assemble the data)

    Parent ID

    Display Name

    The ID, and display name are properly bound. Again it displays properly

    However on the MouseUp event, when I get the selected node (using single selection mode), I cannot find a way to get to the datarow or the ID of the selected node. I can’t even get to the display name. If I examine the node in the debugger, I can see a private variable that contains the corresponding datarow, but the node inexplicably does not expose this.

    How could this control be useful to anyone without the ability to get back to the key value for the row that fed the node?

    Am I missing something or is it not possible to get to the underlying data that sourced the node in this bound control? I found a solution but it is for the ASP.NET version of this control and the properties in that solution are not in the Winforms control.

    HELP!

    I am stalled until this is fixed.

  • Posted 16 April 2019, 5:05 pm EST

    Hi,

    Have you tried the C1TreeNode.GetValue() method. It should give you a DataRow object for the corresponding node. You can use something like this:

    var node = c1TreeView1.SelectedNodes.First();
    var dataRow = node.GetValue() as DataRow;
    int nodeID = dataRow["ID"];
    

    Regards,

    Jitender

  • Posted 17 April 2019, 5:47 am EST

    This works, but the documentation is ambiguous to say the best.

  • Posted 21 April 2019, 3:11 pm EST

    Hi,

    Thanks for the feedback. I have forwarded a request to the docs team to consider adding this in the documentation for C1TreeView.

    Regards,

    Jitender

Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels