SelectedNodes on treeview count is wrong

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

    Posted 18 Apr 2008 Link to this post

    I have a treeview where allow multiselect is set to true. When I select one node, the SelectedNodes.Count = 1 in the Selected event handler.

    I then select a different node. I am not performing a multiselect or holding the shit or ctrl key, and in the Selected event handler the SelectedNodes.Count = 2.

    I thought that the Selected event handler fired after the selection occurred. If so, how is it that my count of SelectedNodes is anything other then 1?

    Is this a bug or is there a work around for this?


  2. Jordan
    Admin
    Jordan avatar
    547 posts

    Posted 21 Apr 2008 Link to this post

    Hello mike scardina,

    This behavior is due to the fact that the previously selected nodes are cleared on MouseUp because of certain drag and drop scenarios with multiple nodes. However, you are right that this is not entirely correct behavior. It will be corrected in the next service pack of RadControls for WinForms.

    For now, you could check if Ctrl or Shift key is pressed in the following way:

    void radTreeView1_Selected(object sender, EventArgs e) 
        bool multiSelect = (Control.ModifierKeys == Keys.Control || Control.ModifierKeys == Keys.Shift); 
        int selectedNodeCount = (multiSelect) ? this.radTreeView1.SelectedNodes.Count : 1; 

    I hope this helps. If you have any further questions, please contact me.

    Kind regards,
    Jordan
    the Telerik team

    Instantly find answers to your questions at the new Telerik Support Center
  3. UI for WinForms is Visual Studio 2017 Ready
  4. Mike
    Mike avatar
    76 posts
    Member since:
    Nov 2004

    Posted 11 Sep 2008 Link to this post

    Was this problem resolved in Q2 2008 SP1?

    I want to know if I should upgrade my controls.
  5. Jordan
    Admin
    Jordan avatar
    547 posts

    Posted 12 Sep 2008 Link to this post

    Hi mike scardina,

    Unfortunately, this fix did not make it in the Q2 2008 SP1 release, due to other tasks with higher priority. However, I have increased the priority of that issue and scheduled it to be fixed for the Q3 2008 release, due in about 6 weeks.
     
    Let us know if this timeframe is ok for you. If not, we will have to figure out an alternative solution.


    All the best,
    Jordan
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Back to Top