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

How to disable CommandButton in cell element adding new row.

2 Answers 63 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Amador
Top achievements
Rank 1
Amador asked on 16 Sep 2011, 12:20 PM
Hi,

I want to disable the commandbutton when the user is adding a new row, but I'm not finding the way to do this.

Please I need some Help. Thanks.

2 Answers, 1 is accepted

Sort by
0
Accepted
Emanuel Varga
Top achievements
Rank 1
answered on 16 Sep 2011, 12:35 PM
Hello Amador,

Just handle the CellFormatting event and do something like this:
void radGridView1_CellFormatting(object sender, CellFormattingEventArgs e)
{
    var commandCell = e.CellElement as GridCommandCellElement;
    if (commandCell == null)
    {
        return;
    }
 
    commandCell.CommandButton.Enabled = !(e.Row is GridViewNewRowInfo);
}

Hope this helps, if you have any other questions or comments, please let me know,

Best Regards,
Emanuel Varga

Telerik WinForms MVP
0
Amador
Top achievements
Rank 1
answered on 16 Sep 2011, 04:18 PM
Gracias.

This was what I'm looking for.

commandCell.CommandButton.Enabled = !(e.Row is GridViewNewRowInfo);


Thanks.
Tags
GridView
Asked by
Amador
Top achievements
Rank 1
Answers by
Emanuel Varga
Top achievements
Rank 1
Amador
Top achievements
Rank 1
Share this question
or