Add Button to Node

7 posts, 0 answers
  1. Mike
    Mike avatar
    76 posts
    Member since:
    Nov 2004

    Posted 01 Jun 2009 Link to this post

    Hi Guys,

    Can you add a button to a treeview node?

    I need to give my client the ability fire an event on a specific node, but nice I have various other functionality tied into the tree already I don't really want to add a button below the tree to provide this event.

    So...  Can I have a node like this.

    Node Text  - (Button)

    When the user clicks a button next to the node it fires off an event.  Maybe the button would select the node so I could get the info off the node tag.

    Let me know.

    ~Mike
  2. Victor
    Admin
    Victor avatar
    1351 posts

    Posted 02 Jun 2009 Link to this post

    Hello Mike,

    Thank you for writing. Please specify exactly what is your case. What kind of event do you need? Maybe we can add this event directly in RadTreeView in future. I have the feeling that you can proceed fine without a button. I am looking forward to your reply.

    Best wishes,
    Victor
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
  3. UI for WinForms is Visual Studio 2017 Ready
  4. Mike
    Mike avatar
    76 posts
    Member since:
    Nov 2004

    Posted 02 Jun 2009 Link to this post

    Hi Victor,

    Let me setup the screen for you…

    The user is presented a list of documents in a treeview.  They can re-order the documents via drag & drop (one or many), delete them from the list (one or many), or denote them as a special document type (one or many – special type also changes the node icon).

    Each one of these functionalities are currently being handled via buttons below the treeview.  So if the user decides to re-order they would update the DB via the update order button.  If they want to delete one or several documents they select the item(s) and click the delete button (updates DB).  If they want to denote the document as a special type they select one or several and click the type button (updates DB).

    With the new requested functionality the user wanted to have an ‘edit’ button next to a specific document type that meet certain criteria.  IE:  Only document types of ‘endorsement’ that are in ‘released’ status would see an edit button next to the node.

    When the user clicks the ‘edit’ button we do a bunch of magic that would remove the current document, and replace it with a new document with a status of ‘work in progress’.

    Now, with that said, I could easily add another button below the treeview that would handle this functionality – figure out what node was selected, remove it, add a new node, and do the document creation process.  But, if there was a way to add a button next to the node text it would save me a lot of checking to see if the node is the correct document type and status, before I process.  Also, it would also stop me from having to check if they selected many documents – this functionality can only be performed on one document at a time.

    I hope I made myself clear.

    ~Mike

  5. Victor
    Admin
    Victor avatar
    1351 posts

    Posted 05 Jun 2009 Link to this post

    Hello Mike,

    Thank you for the in-depth explanation. In order to place a button next to the nodes, you will have to inherit RadTreeView and modify its layout. But that will be hard to do so I suggest creating a context menu for each node and adding options in it depending on your criteria. Here is how you can associate a context menu to a RadTreeNode. The first node in this example:

    RadDropDownMenu menu = new RadDropDownMenu();  
    menu.Items.Add(new RadMenuItem("Action1"));  
    menu.Items.Add(new RadMenuItem("Action2"));  
    menu.Items.Add(new RadMenuItem("Action3"));  
    this.radTreeView1.Nodes[0].ContextMenu = menu; 

    The only thing left to do is to subscribe to the Click event of each menu item and perform the needed actions. Also if you want to disable a menu item you have to set its Enabled property to false. Do not hesitate to write back if you need further assistance.

    Sincerely yours,
    Victor
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
  6. Srikanth
    Srikanth avatar
    10 posts
    Member since:
    Jul 2010

    Posted 23 Jul 2010 Link to this post

    Hi Victor,


    i have to add Button to each  node in the Tree view. if i click the button,i have to open popup using Radwindow. Please give an idea how to add Button to each node.

    Thanks and Regards,
    Srikanth.
  7. Victor
    Admin
    Victor avatar
    1351 posts

    Posted 28 Jul 2010 Link to this post

    Hi Srikanth,

    Thank you for writing.

    As I stated in my previous post RadTreeView does not support custom elements in its nodes, your best bet is to use a context menu that is specific for each node.

    Write again if you have other questions.

    Regards,
    Victor
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  8. Stefan
    Admin
    Stefan avatar
    2891 posts

    Posted 22 Mar 2011 Link to this post

    Hi Mike,

    Please note that in Q1 2011 we have introduced a major upgrade of RadTreeView control, which is now virtualized and fully customizable. Feel free to download the latest release and try it out. For more information on our latest release refer to this blog post.
     
    Best wishes,
    Stefan
    the Telerik team
Back to Top
UI for WinForms is Visual Studio 2017 Ready