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

Treeview node selection

7 Answers 432 Views
Treeview
This is a migrated thread and some comments may be shown as answers.
Jean-Marc
Top achievements
Rank 1
Jean-Marc asked on 23 Aug 2011, 06:17 PM
Hi,
I have problems with with Q2 2011 :
-  every node of a treeview in my application is selectable not only by clicking over the node text, but also if I click on the line containing the node, while my goal is that only when I click on the text  the node is selected; if I click outside the text of the node for example on the same line of the node, no nodes must be selected.

I Have an other problem with the RadToolStripSeparatorItem: I can' t set the width of the line or change the style of the item; my goal is to create a thinner line than the default one.
As attachement a screenshot of the desired effect and the actual effect

7 Answers, 1 is accepted

Sort by
0
Ivan Petrov
Telerik team
answered on 26 Aug 2011, 07:53 AM
Hello Jean-Marc,

Thank you for writing and for the attached screen shots.

To achieve this selection mode in RadTreeView you should set the property FullRowSelect to false. The RadToolStrip is an obsolete control and I highly recommend you to use RadCommandBar instead. As for the width of the RadToolStripSeparatorItem, all RadControls have a MaxSize property which you can use to modify the size of the separator.

I hope this will help. If you have further questions I would be glad to help.

All the best,
Ivan Petrov
the Telerik team

Thank you for being the most amazing .NET community! Your unfailing support is what helps us charge forward! We'd appreciate your vote for Telerik in this year's DevProConnections Awards. We are competing in mind-blowing 20 categories and every vote counts! VOTE for Telerik NOW >>

0
Jean-Marc
Top achievements
Rank 1
answered on 26 Aug 2011, 10:38 AM
I have already tried to use the property FullRowSelect to false in  the radtreeView control, but it doesn' t seem to have effects. I also tried to set to false the FullRowSelect  in the treeviewelement property of the control, but no effects: the line containing the node of the treeview is fully selectable, not only the node.

I also tried to set the maxsize of the RadToolStripSeparatorItem to 1 but no changes are visible
Are there other controls available similar to RadToolStripSeparator item to use? I use it in a RadStatusStrip to divide elements.
0
Ivan Petrov
Telerik team
answered on 31 Aug 2011, 08:42 AM
Hello Jean-Marc,

Thank you for your reply.

The FullRowSelect property is working as expected on my side with your version of the RadControls suite. Could you please check if you are not setting it somewhere in your code. Refer to the attached video for the behavior on my side. You can open it in your browser.
You can insert any RadElement into the RadStatusStrip items collection. Consider the following code snippet which inserts two button elements and a LightVisualElement for separator:

RadButtonElement button1 = new RadButtonElement("button1");
RadButtonElement button2 = new RadButtonElement("button2");
 
LightVisualElement element = new LightVisualElement();
element.DrawFill = true;
element.GradientStyle = Telerik.WinControls.GradientStyles.Solid;
element.BackColor = Color.Red;
element.MaxSize = new Size(1, 0);
element.MinSize = new Size(1, 0);
 
this.radStatusStrip1.Items.Add(button1);
this.radStatusStrip1.Items.Add(element);
this.radStatusStrip1.Items.Add(button2);

Should you have further questions I would be glad to help.

Regards,
Ivan Petrov
the Telerik team

Thank you for being the most amazing .NET community! Your unfailing support is what helps us charge forward! We'd appreciate your vote for Telerik in this year's DevProConnections Awards. We are competing in mind-blowing 20 categories and every vote counts! VOTE for Telerik NOW >>

0
Jean-Marc
Top achievements
Rank 1
answered on 31 Aug 2011, 03:15 PM
Thank you for your explanation:
LightVisualElement  is the right solution for my application and now the statusstrip looks fine.

My problem with the radtreeview is that the event "mouseOver" when I move over a node in the treenode is generated not only when the mouse is over the text of the node, but also when the mouse is over the line containing the node.
My goal is to highlight the node of the treeview only when the mouse pointer is over the text of the node, but not when the mouse pointer is over the line containing the node but not over the text of the node.
In the prevous version of the Telerik graphic libraries the nodes of a treeview where highlighted only when the mouse pointer was over the node text with the mouseover event.  
0
Ivan Petrov
Telerik team
answered on 02 Sep 2011, 02:50 PM
Hi Jean-Marc,

I am glad we are making some progress.

What you describe as a desired behavior for highlighting in the RadTreeView is exactly how the RadTreeView behaves when FullRowSelect is set to false. What is not as you wish is the NodeMouseMove event which, indeed, fires not only when you hover the text part of the node, but also the blank part. For your case you can use the MouseMove of the RadTreeView and check whether you are over the text part of a TreeNode. Here is an example which demonstrates how to do that:

private void radTreeView1_MouseMove(object sender, MouseEventArgs e)
{
  RadElement element = this.radTreeView1.ElementTree.GetElementAtPoint(e.Location);
             
  TreeNodeElement treeNodeElement = element as TreeNodeElement;
 
  if (treeNodeElement == null)
  {
    return;
  }
 
  if (treeNodeElement.ContentElement.IsMouseOverElement)
  {
    //Do something
  }
}

I hope this will work for you. If you need further assistance I would be glad to provide it. Regards,
Ivan Petrov
the Telerik team

Thank you for being the most amazing .NET community! Your unfailing support is what helps us charge forward! We'd appreciate your vote for Telerik in this year's DevProConnections Awards. We are competing in mind-blowing 20 categories and every vote counts! VOTE for Telerik NOW >>

0
Marian
Top achievements
Rank 1
answered on 17 Jul 2015, 09:16 AM

Hi Ivan, I have a similar issue. In my case I have checkboxes enabled for the tree nodes.

Setting FullRowSelect to false does not help if you click on a checkbox the node is still selected. 

What can I do to skip node selection when I am just checking the node and not selecting it (selecting the text of the node)

0
Dess | Tech Support Engineer, Principal
Telerik team
answered on 17 Jul 2015, 12:51 PM
Hello Marian,

Thank you for writing.

Note that the is a part of the TreeNodeElement. That is why when clicking over it the associated node element is selected. This is desired behavior. In order to prevent node selection when clicking the you can create a custom RadTreeView and override its OnMouseDown method:
public class CustomTreeView : RadTreeView
{
    public override string ThemeClassName 
    {
        get
        {
            return typeof(RadTreeView).FullName; 
        }
    }
 
    protected override void OnMouseDown(MouseEventArgs e)
    {
        TreeNodeCheckBoxElement cb = this.ElementTree.GetElementAtPoint(e.Location) as TreeNodeCheckBoxElement;
        if (cb != null)
        {
            cb.Checked = !cb.Checked ;
            return;
        }
        base.OnMouseDown(e);
    }
}

I hope this information helps. Should you have further questions, I would be glad to help.
 
Regards,
Dess
Telerik
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 Feedback Portal and vote to affect the priority of the items
Tags
Treeview
Asked by
Jean-Marc
Top achievements
Rank 1
Answers by
Ivan Petrov
Telerik team
Jean-Marc
Top achievements
Rank 1
Marian
Top achievements
Rank 1
Dess | Tech Support Engineer, Principal
Telerik team
Share this question
or