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

GridviewCheckBoxColumn check value incorrect when using shorcutkey for button

2 Answers 64 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Selvamani
Top achievements
Rank 1
Selvamani asked on 04 Nov 2011, 01:45 PM
Hi,

    i have created a sample application to produce the bug. the application contains gridview with one cell which is gridviewcheckcolumn and a rad button to show the messagebox saying whether the check box is checked or not in the gridview.
    
    when i check the checkbox and if i press the button mesage box showing checked but when i press shortcut key for the button its not working correctly.

    there is a scenarion in my project where we have shortcut key for the button and it behaves like as i said above, so any suggestions on this regard will be helpful for me to solve this issue

private void Form1_Load(object sender, EventArgs e)
       {
           GridViewDataRowInfo row = this.radGridView1.Rows.AddNew();
       }
 
       private void radButton1_Click(object sender, EventArgs e)
       {
           string name = radGridView1.Rows[0].Cells[0].Value.ToString();
           if (radGridView1.Rows[0].Cells["Select"].Value.ToString() == "True")
               MessageBox.Show("Checked");
           else
               MessageBox.Show("UnChecked");          
       }

Thanks,
Selva

2 Answers, 1 is accepted

Sort by
0
Accepted
Stefan
Telerik team
answered on 10 Nov 2011, 09:41 AM
Hi Selvamani,

Thank you for writing.

The reason for the observed behavior is caused by the fact that when you click the check box, the check box editor is still in edit mode and executing the shortcut of the button, will not get its new value. While, when you press the button, the grid looses focus, the editor is closed, and the new value is submitted. This is why you are getting correct value.

In order to make both cases working, subscribe to the ValueChanged event of RadGridView and if the CurrentColumn is your check box column, call the EndEdit method of RadGridView:
void radGridView1_ValueChanged(object sender, EventArgs e)
{
    if (radGridView1.CurrentColumn.Name == "Select")
    {
        radGridView1.EndEdit();
    }
}

I hope that you find this information helpful. 
 
Kind regards,
Stefan
the Telerik team

Q2’11 SP1 of RadControls for WinForms is available for download (see what's new); also available is the Q3'11 Roadmap for Telerik Windows Forms controls.

0
Selvamani
Top achievements
Rank 1
answered on 10 Nov 2011, 11:13 AM
Hi,

    its working fine now. thanks for the kind suggestion.

regard's
Selva
Tags
GridView
Asked by
Selvamani
Top achievements
Rank 1
Answers by
Stefan
Telerik team
Selvamani
Top achievements
Rank 1
Share this question
or