Debug my code
-
Hi CodeProject, I have created a form with a datagrid, my requirement is that when the user clicks "F5" I want to update a certain column with the current time. I defined a DataGridTableStyle and a DataGridTextBoxColumn object. I attached an event handler to the DataGridTextBoxColumn.TextBox.KeyUp property. So now when I hit "F5" the column is updated, but alas, as soon as I navigate to a different line, the row disappears! Am I doing something wrong, or is this a bug? Maybe someone has an different way of doing this? Anyways, this is my code for the KeyUp event: private void dataGridColumn1_TextBox_KeyUp(object sender, KeyEventArgs kea) { if (kea.KeyCode == Keys.F5) { DataRowView drv = (DataRowView)dataGrid1.BindingContext [dataGrid1.DataSource].Current; drv["Col1"] = DateTime.Now.ToLongTimeString(); } } Thanks