Grids and Deleting a Row

I am having some strange happenings in my grid. I believe things were working fine for several weeks. A tester noticed that a record deleted from the grid was not being deleted. Am I reading wrong or don't you just have to issue an update after a row is deleted from the grid to have it physically removed from the table?

So I researched this forum and found your code to remove a record by hooking the delete key as follows:

Private Sub GridPhone_CurrentCellKeyDown(ByVal sender As Object, ByVal e As KeyEventArgs) Handles GridPhone.CurrentCellKeyDown

Dim cc As GridCurrentCell = Me.GridPhone.CurrentCell
If e.KeyData = Keys.Delete And Not cc.IsEditing Then
Me.GridPhone.DeleteRecordsAtRowIndex(cc.RowIndex, cc.RowIndex)
daPhone.Update(DsPhone1.tblPhone)
End If

What I am finding is the delete key is removing the record from the grid before this code is executed. But issuing an update produces no results. If I debug There is no record at -1.

I could code this by hand if I could keep the delete key from removing the record first.

Any suggestions?

Thanks,

Tom

2 Replies

TA Tom Affholter July 16, 2007 09:21 PM UTC

I disabled the delete key be turning off delete (enableremove) from the grid. I can hard code a solution to my challenge but I really need some idea why my previous method was not working.

Thanks,

Tom


HA haneefm Syncfusion Team July 16, 2007 09:26 PM UTC

Hi Tom,

I tried to reproduce the problem you reported by adding a GridDataBoundGrid to form with a button and this handler.

private void button1_Click(object sender, System.EventArgs e)
{
Console.WriteLine(dt.Rows.Count);
this.gridDataBoundGrid1.DeleteRecordsAtRowIndex(1,1);
Console.WriteLine(dt.Rows.Count);
}

dt is a DataTable that I had set to be the grid''s DataSource in formload. With this code I do not see a problem (using Essentail Studio 5.1).

Can you tell me how to see this problem in one of our samples, or can you post a sample project showing the problem?

Best regards,
Haneef

Loader.
Up arrow icon