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

SelectedNodes on treeview count is wrong

3 Answers 109 Views
Treeview
This is a migrated thread and some comments may be shown as answers.
Mike
Top achievements
Rank 2
Mike asked on 18 Apr 2008, 03:59 PM
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?


3 Answers, 1 is accepted

Sort by
0
Jordan
Telerik team
answered on 21 Apr 2008, 12:25 PM
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
0
Mike
Top achievements
Rank 2
answered on 11 Sep 2008, 05:17 PM
Was this problem resolved in Q2 2008 SP1?

I want to know if I should upgrade my controls.
0
Jordan
Telerik team
answered on 12 Sep 2008, 04:22 PM
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.
Tags
Treeview
Asked by
Mike
Top achievements
Rank 2
Answers by
Jordan
Telerik team
Mike
Top achievements
Rank 2
Share this question
or