How to disable CommandButton in cell element adding new row.

3 posts, 1 answers
  1. Amador
    Amador avatar
    4 posts
    Member since:
    Feb 2009

    Posted 16 Sep 2011 Link to this post

    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. Answer
    Emanuel Varga
    Emanuel Varga avatar
    1336 posts
    Member since:
    May 2010

    Posted 16 Sep 2011 Link to this post

    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
  3. Amador
    Amador avatar
    4 posts
    Member since:
    Feb 2009

    Posted 16 Sep 2011 Link to this post

    Gracias.

    This was what I'm looking for.

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


    Thanks.
Back to Top