Can CheckBox be set as "ReadOnly"?

6 posts, 1 answers
  1. Ben Hayat
    Ben Hayat avatar
    892 posts
    Member since:
    May 2008

    Posted 14 Feb 2011 Link to this post

    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
  2. Answer
    Petar Mladenov
    Admin
    Petar Mladenov avatar
    2891 posts

    Posted 17 Feb 2011 Link to this post

    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
  3. DevCraft banner
  4. Ben Hayat
    Ben Hayat avatar
    892 posts
    Member since:
    May 2008

    Posted 17 Feb 2011 Link to this post

    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
  5. Petar Mladenov
    Admin
    Petar Mladenov avatar
    2891 posts

    Posted 22 Feb 2011 Link to this post

    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!
  6. Ben Hayat
    Ben Hayat avatar
    892 posts
    Member since:
    May 2008

    Posted 22 Feb 2011 Link to this post

    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
  7. Petar Mladenov
    Admin
    Petar Mladenov avatar
    2891 posts

    Posted 23 Feb 2011 Link to this post

    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!
Back to Top
DevCraft banner