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

Can CheckBox be set as "ReadOnly"?

5 Answers 164 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
Ben Hayat
Top achievements
Rank 2
Ben Hayat asked on 14 Feb 2011, 09:45 PM
Is it possible to set the CheckBox (Check State property) as readonly, so the user can not change it?
I would like to use this checkbox to tell the user if this node is a "Private" or "Public" by using the checkbox. However, the program will read certain data from database to determine that and not the user. So at runtime I like to set that but the user can not change it.
If not, how else can I show some sort of indicator that the item is private or public?
Thanks!
..Ben

5 Answers, 1 is accepted

Sort by
0
Accepted
Petar Mladenov
Telerik team
answered on 17 Feb 2011, 02:12 PM
Hi Ben Hayat,

You can edit the default style of the RadTreeViewItem and apply it to particular items.
You can modify the CheckBox to be Disabled for or to exclude it from the template.
The described approach is realized in the attached solution, so please give it a try and let me know if it satisfies you.

Greetings,
Petar Mladenov
the Telerik team
0
Ben Hayat
Top achievements
Rank 2
answered on 17 Feb 2011, 03:22 PM
Thank you Petar for the reply and test program. I'll look through it. Meanwhile, for my case I'm trying to figure out if there is a better solution than using disabled checkbox.

..Ben
0
Petar Mladenov
Telerik team
answered on 22 Feb 2011, 02:22 PM
Hi Ben Hayat,

Actually, it appears that there is an easier way to achieve the desired effect. you can explicitly set the OptionType to None like so:
<telerik:RadTreeView Name="treeView" 
                                 Width="150"
                                 HorizontalAlignment="Left"
                                 IsOptionElementsEnabled="True"
                                 ItemsOptionListType="CheckList">
                <telerik:RadTreeViewItem Header="Sport" OptionType="None" />
                <telerik:RadTreeViewItem Header="EnterTainment" />
            </telerik:RadTreeView>
Please let us know if this approach helps you.

Regards,
Petar Mladenov
the Telerik team
Registration for Q1 2011 What’s New Webinar Week is now open. Mark your calendar for the week starting March 21st and book your seat for a walk through all the exciting stuff we ship with the new release!
0
Ben Hayat
Top achievements
Rank 2
answered on 22 Feb 2011, 05:31 PM
Hi Petar;

I'm not sure the OptionType=None, would help me. At runtime I do want to set the Item to "Checked" or "Unchecked", except I don't want the user to be able to change it. Are you saying with OptionType=none I can do that?

Thanks!
..Ben
0
Petar Mladenov
Telerik team
answered on 23 Feb 2011, 01:10 PM
Hello Ben Hayat,

Setting the OptionType of some particular RadTreeViewItem doesn't restrict you to change its IsChecked property. You can examine this in the attached solution.
However, you can elaborate more on your scenario; how will the data be loaded, how will the user change the CheckState ( IsChecked  of the items, how you bind your tree and etc. This way we could provide you with the best approach for your situation. A runnable sample would also be highly appreciated. Thank you for your cooperation.

Kind regards,
Petar Mladenov
the Telerik team
Registration for Q1 2011 What’s New Webinar Week is now open. Mark your calendar for the week starting March 21st and book your seat for a walk through all the exciting stuff we ship with the new release!
Tags
TreeView
Asked by
Ben Hayat
Top achievements
Rank 2
Answers by
Petar Mladenov
Telerik team
Ben Hayat
Top achievements
Rank 2
Share this question
or