Unplanned
Last Updated: 27 Dec 2016 11:16 by ADMIN
ADMIN
Dess | Tech Support Engineer, Principal
Created on: 06 Dec 2016 07:01
Category: GridView
Type: Bug Report
1
FIX. RadGridView - RadButton.Click event is not fired when UserAddingRow is canceled
To reproduce: add a RadGridView and a RadButton on the form. Use the following code snippet:

public RadForm1()
{
    InitializeComponent();
    this.radGridView1.Columns.Add("Col1");
    this.radGridView1.Columns.Add("Col2");
    for (int i = 0; i < 5; i++)
    {
        this.radGridView1.Rows.Add(i, "Item" + i);
    }
    this.radGridView1.AutoSizeColumnsMode = Telerik.WinControls.UI.GridViewAutoSizeColumnsMode.Fill;
    this.radGridView1.RowValidating += radGridView1_RowValidating;
    this.radGridView1.UserAddingRow += radGridView1_UserAddingRow;
}

private void radGridView1_UserAddingRow(object sender, Telerik.WinControls.UI.GridViewRowCancelEventArgs e)
{
    e.Cancel = true;
}

private void radGridView1_RowValidating(object sender, Telerik.WinControls.UI.RowValidatingEventArgs e)
{
    if (e.Row.IsModified && e.Row is GridViewDataRowInfo)
    { 
        e.Cancel = true;
    }
}

private void radButton1_Click(object sender, EventArgs e)
{ 
    RadMessageBox.Show("Clicked");
}

1. Select a data cell and activate the editor. Enter some new value and click the button. The Click event is fired.
2. Select the new row and activate the editor. Enter some value and click the button. The Click event is NOT fired.

Workaround: use the CellValidating event instead.
0 comments