We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy.
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Grids and Deleting a Row

Thread ID:

Created:

Updated:

Platform:

Replies:

64199 Jul 16,2007 09:02 PM UTC Jul 16,2007 09:26 PM UTC Windows Forms 2
loading
Tags: GridControl
Tom Affholter
Asked On July 16, 2007 09:02 PM UTC

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

Tom Affholter
Replied On 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

haneefm [Syncfusion]
Replied On 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

CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

;