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

Selected Event

1 Answer 90 Views
Treeview
This is a migrated thread and some comments may be shown as answers.
Frédéric
Top achievements
Rank 1
Frédéric asked on 13 Aug 2008, 07:37 PM

Hi,

Sorry to ask you so much question but I still have a little problem.

I'm using the Selected event and I have a problem.

I'm using multi selection.

>I select 1 node with the
>Then, I click into another non selected node.


I have the feeling that the Selected event is fired before the first node is unselected because when I go to Nodes.selected.count I have 2 node and I should have just one!

Is it normal?

I check the documentation and they say I should use OnSelectionChange but I'm not able to use it. (I'm not an experienced programmer... :-( )

Can you please give me a sample code ?

Thanks in advance for your help.

1 Answer, 1 is accepted

Sort by
0
Accepted
Jordan
Telerik team
answered on 15 Aug 2008, 02:18 PM
Hello Frédéric,

The current implementation of the selection functionality clears the old selection on mouse up when multi-select is on. That is due to the specifics of drag-and-drop and it is by design.

You could try examining the selected nodes in the mouse up handler like in the code below:
 
public Form1() 
        { 
            InitializeComponent(); 
            this.radTreeView1.AllowMultiselect = true
 
            this.radTreeView1.Selected += new EventHandler(radTreeView1_Selected); 
            this.radTreeView1.MouseUp += new MouseEventHandler(radTreeView1_MouseUp); 
        } 
 
        private bool selectionChanged = false
        void radTreeView1_MouseUp(object sender, MouseEventArgs e) 
        { 
            if (this.selectionChanged) 
            { 
                this.selectionChanged = false
                Console.WriteLine("radTreeView1_Selected"); 
                for (int i = 0; i < this.radTreeView1.SelectedNodes.Count; i++) 
                { 
                    Console.WriteLine(this.radTreeView1.SelectedNodes[i].ToString()); 
                } 
                Console.WriteLine(); 
            } 
        } 
 
        void radTreeView1_Selected(object sender, EventArgs e) 
        { 
            this.selectionChanged = true
        } 

For a future release we will try to find a way to correct this behavior without breaking the drag and drop functionality. Unfortunately, I cannot give you a specific time frame for that at the moment.


Kind regards,
Jordan
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Tags
Treeview
Asked by
Frédéric
Top achievements
Rank 1
Answers by
Jordan
Telerik team
Share this question
or