This is a migrated thread and some comments may be shown as answers.

RadTree with Context Menu using windows forms

8 Answers 313 Views
Treeview
This is a migrated thread and some comments may be shown as answers.
SHD
Top achievements
Rank 1
SHD asked on 28 Feb 2008, 03:25 PM
I want to build a RadTree with a Context Menu using a windows forms application. Can you please point me to some code samples/sample application?
I found the online demos for the ASP.Net RadTree, but did not see any samples for their windows counterpart.

Thank you.

8 Answers, 1 is accepted

Sort by
0
SHD
Top achievements
Rank 1
answered on 28 Feb 2008, 08:26 PM
I drag and dropped a RadTreeView control onto a windows form.

For one, it shows the control on a panel below the form, not on the form itself. In the .cs code I am doing this:

InitializeComponent();

List<NameValue> list = new List<NameValue>();
list.Add(
new NameValue("node1", "value1"));
list.Add(
new NameValue("node2", "value2"));
list.Add(
new NameValue("node3", "value3"));
radTreeView1.DisplayMember =
"ID";
radTreeView1.ValueMember =
"Value";
radTreeView1.DataSource = list;

I do not see the tree displayed on the form with these 3 nodes.
I have Winforms Q1 2007.

Do you have an idea what is going on?

0
Jordan
Telerik team
answered on 29 Feb 2008, 08:22 AM
Hello SHD,

You can find the online documentation of RadControls for WinForms here:
http://www.telerik.com/help/winforms/Q3_2007/

Here is a help article showing how one can bind a RadTreeView to a List (as in your sample code):
http://www.telerik.com/help/winforms/Q3_2007/RadTreeDataBasics.html

Here is another help article explaining how to use context menus with RadTreeView:
http://www.telerik.com/help/winforms/Q3_2007/RadTreeDesignContextMenus.html

I hope that helps. If you have any further questions do not hesitate to ask.

Greetings,
Jordan
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
SHD
Top achievements
Rank 1
answered on 29 Feb 2008, 09:48 PM
Thank you for your help. 

Can you please point me to sample code that illustrates how to control the appearance of a radTreeView using themes and styles? Specifically based on some application logic I want to change the background of certain leaf nodes in the tree.

Also, there is a RadMenu object in the ToolBox and a RadMenuStrip object in documentation. Can any of these be used for rendering context menus? I am using the RadDropDownMenu for rendering my context menu.

Thank you in advance.
0
SHD
Top achievements
Rank 1
answered on 03 Mar 2008, 08:21 PM
I have the RadDropDownMenu context menu hooked to a tree.
When I right click and select an option from the context menu, I want to determine the node of the tree on which the context menu was clicked.
Note that this node may not be selected at this point.

Thank you.
0
Boyko Markov
Telerik team
answered on 04 Mar 2008, 10:46 AM
Hello SHD,

To control the appearance of RadTreeNode you have to use some of its properties, such as ForeColor, ForeColor2, BorderColor, BackColor, BackColor2, BackColor3. BackColor4. GradientAngle, GradientPercentage, GradientPercentage2, GradientStyle and NumberOfColors. These are used to control the visual appearance of any Telerik WinForms control. Please, review the documentation on how to change the visual appearance of the controls.

To determine the node of the tree on which the context menu was clicked, subscribe to the MouseUp event of RadTreeView and then add the following code:
  
void radTreeView1_MouseUp(object sender, MouseEventArgs e)
{
    
if (e.Button == MouseButtons.Right)
     {
            RadTreeNode node = this.radTreeView1.GetNodeAt(e.Location.X, e.Location.Y);

            if (node != null)
            {

                // TO DO
            }
      }
}

As to RadMenu and RadMenuStip - they are the same objects. We will rename them all to RadMenuStrip in one of the future versions. The RadDropDownMenu you are currently using should help you achieve your goal.

This should help you. Please write us back if you have other questions.


Regards,

Boyko Markov
the Telerik team


Instantly find answers to your questions at the new Telerik Support Center
0
SHD
Top achievements
Rank 1
answered on 11 Mar 2008, 03:45 PM
Thank you Boyko for the information. It worked for me.

Can you please tell me how can I search for nodes by text in a RadTree?
I see a FindNodeByText on the ASP.Net RadTree but no equivalent on the windows forms RadTree.

Thank you.
0
Nikolay
Telerik team
answered on 14 Mar 2008, 12:40 PM
Hi SHD,

Currently, RadTreeView does not support the FindNodeByText feature. This issue will be addressed for the Q1 2008 release. For the time being, please refer to the following code snippet representing the implementation of the method:
RadTreeNode FindNodeByText(RadTreeNodeCollection nodeCollection, string text)  
{  
    foreach (RadTreeNode node in nodeCollection)  
    {  
        if ((node.Text == text) && (node != this.radTreeView1.SelectedNode))  
        {  
            return node;  
        }  
        RadTreeNode result = this.FindNodeByText(node.Nodes, text);  
        if (result != null)  
        {  
            return result;  
        }  
    }  
 
    return null;  

I hope this helps. If you have additional questions, do not hesitate to contact me.

Regards,
Nikolay
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
Stefan
Telerik team
answered on 23 Mar 2011, 04:09 PM
Hi SHD,

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.

Kind regards,
Stefan
the Telerik team
Tags
Treeview
Asked by
SHD
Top achievements
Rank 1
Answers by
SHD
Top achievements
Rank 1
Jordan
Telerik team
Boyko Markov
Telerik team
Nikolay
Telerik team
Stefan
Telerik team
Share this question
or