Treeview node selection

8 posts, 0 answers
  1. Jean-Marc
    Jean-Marc avatar
    93 posts
    Member since:
    Mar 2011

    Posted 23 Aug 2011 Link to this post

    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
  2. Ivan Petrov
    Admin
    Ivan Petrov avatar
    701 posts

    Posted 26 Aug 2011 Link to this post

    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 >>

  3. UI for WinForms is Visual Studio 2017 Ready
  4. Jean-Marc
    Jean-Marc avatar
    93 posts
    Member since:
    Mar 2011

    Posted 26 Aug 2011 Link to this post

    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.
  5. Ivan Petrov
    Admin
    Ivan Petrov avatar
    701 posts

    Posted 31 Aug 2011 Link to this post

    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 >>

  6. Jean-Marc
    Jean-Marc avatar
    93 posts
    Member since:
    Mar 2011

    Posted 31 Aug 2011 Link to this post

    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.  
  7. Ivan Petrov
    Admin
    Ivan Petrov avatar
    701 posts

    Posted 02 Sep 2011 Link to this post

    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 >>

  8. Marian
    Marian avatar
    3 posts
    Member since:
    Mar 2014

    Posted 17 Jul 2015 in reply to Ivan Petrov Link to this post

    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)

  9. Dess
    Admin
    Dess avatar
    1609 posts

    Posted 17 Jul 2015 Link to this post

    Hello Marian,

    Thank you for writing.

    Note that the check-box 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 check-box 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
Back to Top
UI for WinForms is Visual Studio 2017 Ready