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

Error Checkbox in radGridView

1 Answer 182 Views
GridView
This is a migrated thread and some comments may be shown as answers.
kenny
Top achievements
Rank 1
kenny asked on 16 Jul 2010, 04:01 AM
I add column checkbox in radGridView. When I check it error " Specified cast is not valid "

Code:
if (this.radGridView1.ActiveEditor is RadCheckBoxEditor)
{
        bool value = (bool)this.radGridView1.ActiveEditor.Value;
}

Help Me. Thank You.

1 Answer, 1 is accepted

Sort by
0
Accepted
Svett
Telerik team
answered on 19 Jul 2010, 08:10 PM
Hi kenny,

The exception is thrown because you have tried to cast the RadCheckBoxEditor's value to a bool type. The editor value is from type ToggleState, because of its tree state feature. Hence, you need to cast it to ToggleState type:
 
RadCheckBoxEditor checkBox = this.radGridView2.ActiveEditor as RadCheckBoxEditor;
if (checkBox != null)
{
    Telerik.WinControls.Enumerations.ToggleState state = (Telerik.WinControls.Enumerations.ToggleState)checkBox.Value;
    bool isTrue = state == Telerik.WinControls.Enumerations.ToggleState.On;
}

Sincerely yours,
Svett
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Tags
GridView
Asked by
kenny
Top achievements
Rank 1
Answers by
Svett
Telerik team
Share this question
or