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

Enable disable checkbox in RadGridView

3 Answers 948 Views
Calendar, DateTimePicker, TimePicker and Clock
This is a migrated thread and some comments may be shown as answers.
Rajeev
Top achievements
Rank 1
Rajeev asked on 11 Apr 2008, 12:22 PM
Hi,

I have RadGridView populated and it has first column as boolean column shown as checkbox on UI. I need to disable some checkbox on RadGridview based on some data on other column (means user can't click or do any operation.) and need to select and Unselect some checkbox. I tried cellformatting event and cellClick event but no success. I treid to access checkboxelement but it don't have any check property. Please help me how to access checkbox cell element at these events. Or is there any other event???

GridViewBooleanColumn

columnA = new GridViewBooleanColumn();

columnA.HeaderTextAlignment =

ContentAlignment.MiddleLeft;

columnA.HeaderText =

"";

columnA.DataField =

"Check";

columnA.ReadOnly =

false;

columnA.Width = 20;

columnA.AllowResize =

false;

columnA.MinWidth = 20;

radDownLoadListGridView.MasterGridViewTemplate.Columns.Add(columnA);


...........................

private void radDownLoadListGridView_CellClick(object sender, GridViewCellEventArgs e)

{

if (e.ColumnIndex == 0)

{

if (radDownLoadListGridView.CurrentRow.Cells[9].Value.ToString().ToLower() == "y")

{

(radDownLoadListGridView.CurrentCell).Column.ReadOnly =

false;

((Telerik.WinControls.UI.

GridCheckBoxCellElement)(radDownLoadListGridView.CurrentCell)).IsReadOnly = false;

((Telerik.WinControls.UI.

GridCheckBoxCellElement)(radDownLoadListGridView.CurrentCell)).IsSelected = true;

}

else

{

(radDownLoadListGridView.CurrentCell).Column.ReadOnly =

false;

}

}

}

3 Answers, 1 is accepted

Sort by
0
Jack
Telerik team
answered on 14 Apr 2008, 10:52 AM
Hello Rajeev,

Thank you for contacting us.

Yes, you can do this by processing the CellFormatting event. Consider the code snippet below:

void radDownLoadListGridView_CellFormatting(object sender, CellFormattingEventArgs e) 
    if (e.CellElement.ColumnIndex == 0) 
    { 
        if ((int)this.radDownLoadListGridView.CurrentRow.Cells[2].Value.ToString().ToLower() == "y"
        { 
            e.CellElement.ColumnInfo.ReadOnly = true
        } 
        else 
        { 
            e.CellElement.ColumnInfo.ReadOnly = false
        } 
    } 

I hope this helps. Feel free to contact me again, if you have other questions.

Sincerely yours,
Jack
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
Prashu
Top achievements
Rank 1
answered on 02 Sep 2013, 01:34 PM
hi all 


i have three checkboxes in grid footer .. if i check one the other two should not allow to check how to implement it. uisng C#
0
George
Telerik team
answered on 05 Sep 2013, 08:42 AM
Hello Prashanth,

Thank you for contacting us.

Can you please provide me with some additional information since the provided so far seems insufficient for me?

I am shooting in the dark here, however if you have three check box columns and you want to always have just one check box checked in a row, you can use the grid's ValueChanging event, which will get triggered when a checkbox value is changed, to uncheck the rest of the check boxes in this row.

Looking forward to your reply.
 
Regards,
George
Telerik
TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for WINFORMS.
Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
Sign up for Free application insights >>
Tags
Calendar, DateTimePicker, TimePicker and Clock
Asked by
Rajeev
Top achievements
Rank 1
Answers by
Jack
Telerik team
Prashu
Top achievements
Rank 1
George
Telerik team
Share this question
or