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

Keeping checkboxes disabled if not bound

5 Answers 149 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Brandon
Top achievements
Rank 1
Brandon asked on 12 Jul 2011, 11:44 PM
I have a variety of checkboxes in a grid where some of them will be bound to underlying objects (boolean) and others that aren't.  Those that aren't bound will not retain checkbox check marks, but they still allow them to be checked.  When clicking off such a cell, the checkbox will go back to being "unchecked".  I want to have control over these unbound checkboxes to make sure they're visibly "unavailable", whether that means preventing any checking activity at all or changing the appearance of the checkbox to a box with a red x or something of the sort just to let users know that the checkbox cannot and should not be used.

I tried hooking into various events such as CellLoaded, etc. but I couldn't find an event that would allow me to check whether or not the checkbox is checked to explicitly make a modification to an individual cell.  For example,  I tried the following which doesn't work:

void radGridView_CellLoaded(object sender, CellEventArgs e)

{

 

if (e.Cell.Content is DataFormCheckBoxField)

{

((

 

DataFormCheckBoxField)e.Cell.Content).IsEnabled = false;

((

 

DataFormCheckBoxField)e.Cell.Content).IsHitTestVisible = false;

((

 

DataFormCheckBoxField)e.Cell.Content).IsReadOnly = true;

}

}

5 Answers, 1 is accepted

Sort by
0
Milan
Telerik team
answered on 15 Jul 2011, 07:51 AM
Hello Brandon,

If the CheckBox controls that are not bound belong to specific column you can easily mark this columns as read-only by setting its ReadOnly property to false. 

Regards,
Milan
the Telerik team

Register for the Q2 2011 What's New Webinar Week. Mark your calendar for the week starting July 18th and book your seat for a walk through of all the exciting stuff we will ship with the new release!

0
Brandon
Top achievements
Rank 1
answered on 15 Jul 2011, 09:32 AM
I don't want to make the entire column read-only, just certain cells within the column.
0
Milan
Telerik team
answered on 21 Jul 2011, 09:11 AM
Hi Brandon,

You could consider using CellStyleSelectors to disable the cells that need to be disabled. You can find more information about Style Selectors here.

Hope this helps.

Greetings,
Milan
the Telerik team

Register for the Q2 2011 What's New Webinar Week. Mark your calendar for the week starting July 18th and book your seat for a walk through of all the exciting stuff we will ship with the new release!

0
Brandon
Top achievements
Rank 1
answered on 25 Jul 2011, 08:01 PM
Thanks Milan!

I think this will work, but I can't find the StyleSelector class to inherit from.  The article you provided the link for says this class should be in the Telerik.Windows.Controls assembly, but I don't see it there.  I see a StyleManager class, but no StyleSelector.

I'm using this version:

Telerik.Windows.Controls, Version=2011.1.419.35

0
Milan
Telerik team
answered on 26 Jul 2011, 08:37 AM
Hello Brandon,

    It seems that I have provided you with a link to our Silverlight documentation where we use our own StyleSelector implementation. For WPF you should use the standard StyleSelector which is defined in the System.Windows.Controls namespace.

Excuse me for the mistake. 

Best wishes,
Milan
the Telerik team

Register for the Q2 2011 What's New Webinar Week. Mark your calendar for the week starting July 18th and book your seat for a walk through of all the exciting stuff we will ship with the new release!

Tags
GridView
Asked by
Brandon
Top achievements
Rank 1
Answers by
Milan
Telerik team
Brandon
Top achievements
Rank 1
Share this question
or