Adding custom controls as treeview nodes

7 posts, 0 answers
  1. Mat
    Mat avatar
    2 posts
    Member since:
    Oct 2012

    Posted 26 Oct 2012 Link to this post

    Hi, Rather than just adding text nodes to a treeview I'd like to be able to a custom composite controls, made up of, for instance, a label, a combo box and a text box. Is this possible? Thanks Mat
  2. Svett
    Admin
    Svett avatar
    728 posts

    Posted 29 Oct 2012 Link to this post

    Hi Mat,

    Thank you for writing.

    You can achieve this easily by creating a custom node element. You can do that by deriving from the TreeNodeElement class. Then you should use the CreateNodeElement event to replace the default one. I am enclosing a sample project that demonstrates how you can do that.

    I hope this helps.

    Kind regards,
    Svett
    the Telerik team
    Q3’11 of RadControls for WinForms is available for download (see what's new). Get it today.
  3. UI for WinForms is Visual Studio 2017 Ready
  4. Mat
    Mat avatar
    2 posts
    Member since:
    Oct 2012

    Posted 01 Nov 2012 Link to this post

    Excellent. Thank you. I'll give it a go.

    Mat
  5. KennethMoss
    KennethMoss avatar
    4 posts
    Member since:
    Apr 2007

    Posted 01 Mar 2015 in reply to Mat Link to this post

    How would you access each control within the nodecontrol for each node?
  6. Stefan
    Admin
    Stefan avatar
    2891 posts

    Posted 02 Mar 2015 Link to this post

    Hi Kenneth,

    RadTreeView uses UI virtualization for its nodes, so accessing the control is not recommended approach. Can you please provide more information about your scenario and I will be glad to help you achieve it.

    I am looking forward to your reply.

    Regards,
    Stefan
    Telerik
     

    Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

     
  7. KennethMoss
    KennethMoss avatar
    4 posts
    Member since:
    Apr 2007

    Posted 13 Mar 2015 in reply to Stefan Link to this post

    I would like to access the node index and corresponding values in the control of that node like in the attachment.
  8. Dess
    Admin
    Dess avatar
    1607 posts

    Posted 18 Mar 2015 Link to this post

    Hello Kenneth,

    Thank you for writing back.

    With RadTreeView you can create custom nodes and display them instead of the default ones. This can be done by creating a custom TreeNodeElement, which will replace the default one in the CreateNodeElement event handler. If the custom elements inside the TreeNodeContentElement are exposed as public properties you will be able to access them in the NodeFormatting events for example.

    However, as my colleague, Stefan remarked, RadTreeView uses UI virtualization for its nodes. Hence, when you preform scrolling, the visual elements will be reused to display the information for the relevant RadTreeNodes. That is why I would recommend you to use the custom elements for updating the corresponding DataBoundItem. Afterwards, you can access the requested information by using the RadTreeNode.DataBoundItem property.

    I hope this information helps. If you have any additional questions, please let me know.

    Regards,
    Dess
    Telerik
     

    Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

     
Back to Top
UI for WinForms is Visual Studio 2017 Ready