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

Disallow Select but stay enabled

2 Answers 40 Views
Treeview
This is a migrated thread and some comments may be shown as answers.
Richard Slade
Top achievements
Rank 2
Richard Slade asked on 22 Jun 2009, 01:29 PM
Hello,

I'm using a tree view for a wizard, to show the users what step they are on. It seems perfect for it as I can use different images for each step.

However, I'd like to be able to keep the control enabled (so that the images and the selected node show in colour), but also disallow the user from selecting a different node. Can you tell me if this is possible, or perhaps some workaround that may do the same thing please?

Thanks

2 Answers, 1 is accepted

Sort by
0
Richard Slade
Top achievements
Rank 2
answered on 22 Jun 2009, 02:18 PM
Hello,

I've figured out an easy way to do this now, so no need for a reply.
Thanks.

For reference, I have done the following:

 

''' <summary>Used to allow the class to internally select an item. Not for user use</summary>

 

 

Private m_AllowSelect As Boolean

 


 

''' <summary>Cancel the selection if a user tries to select another node in the tree</summary>

 

 

Private Sub RadTreeView_Selecting(ByVal sender As System.Object, ByVal e As Telerik.WinControls.UI.RadTreeViewCancelEventArgs) Handles RadTreeView.Selecting

 

e.Cancel =

Not m_AllowSelect

 

 

End Sub

 


and where I need to set the selected item internally....

m_AllowSelect =

True 'temp allow select

 

node.Selected =

True

 

m_AllowSelect =

False 'disallow select

 


This means I can set it programatically from the class, but the users cannot.

0
Victor
Telerik team
answered on 22 Jun 2009, 02:23 PM
Hello Richard Slade,

You can achieve the desired behavior in two ways.

You can either subscribe to RadTreeView Selected event and do this:

void radTreeView1_Selected(object sender, EventArgs e)  
{  
    this.radTreeView1.SelectedNode = null;  

Or you can subscribe to the Selecting event and do this:

void radTreeView1_Selecting(object sender, RadTreeViewCancelEventArgs e)  
{  
    e.Cancel = true;  

I hope that helps. Do not hesitate to write me back if you have further questions.

Best wishes,
Victor
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
Tags
Treeview
Asked by
Richard Slade
Top achievements
Rank 2
Answers by
Richard Slade
Top achievements
Rank 2
Victor
Telerik team
Share this question
or