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

delete row in GridDataBoundGrid

Thread ID:

Created:

Platform:

Replies:

49863 Sep 28,2006 04:07 PM UTC Windows Forms 0
loading
Tags: GridControl
Joe McAnally
Asked On September 28, 2006 04:07 PM UTC

We are allowing user to delete current row by using the delete key. That works fine. (see the 2 routines below) The first routine is called from the Rowdeleted event.

The problem is,,, when you are editing the contents of a cell and you hit the delete key, then the code attempts to delete the row.

I was able to put code in to detect that the cell was in edit mode, and then cancelled the delete. However, the delete key did not delete the character in the cell.

Any ideas?

Thanks in advance.





private void deleteRowHandler(object sender, GridRowRangeEventArgs e)
{
// THIS IS CALLED FROM ROWDELETING EVENT
deleteRow(e);
}



private void deleteRow(GridRowRangeEventArgs e)
{


int iCxOverRowCnt;
int CxOverID = 0;
string moa_from = null;
string moa_to = null;
string confirmMsg = null;

try
{

iCxOverRowCnt = (int)this.getGridRowCount(this.gridDataBoundGridChangeover);
if (iCxOverRowCnt > 0)
{

DataRowView drv = this.getDataRowView(this.gridDataBoundGridChangeover);
CxOverID = (int)drv["ID"];
moa_from = (string)drv["MOA_FROM"];
moa_to = (string)drv["MOA_TO"];
confirmMsg = "OK to Delete? Material # FROM " + moa_from + " Material # To " + moa_to;

DialogResult result = MessageBox.Show(confirmMsg, "Delete Confirmation", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
if (result == DialogResult.Yes)
{
try
{
CurrencyManager cm = (CurrencyManager)this.BindingContext[this.gridDataBoundGridChangeover.DataSource];

if (cm != null && cm.Count > 0)
{

DataRowView dr = this.getDataRowView(this.gridDataBoundGridChangeover);

if (this.gridDataBoundGridChangeover.Binder.IsEditing)
this.gridDataBoundGridChangeover.Binder.EndEdit();

dr.Delete();
this.oleDbChangeover.Update(this.datasetChangeover.CHANGEOVER_DETAILS);
e.Cancel = true;
// If we delete an item from the bottom grid, we need to reload from and to grids becuase the
// deleted moa is now available as a "from" candidate.
this.loadGrids();
}
}
catch (Exception excep)
{
e.Cancel = true;
this.datasetChangeover.RejectChanges();
eventHandler.DisplayFatalError("deleteRow", "Unable to delete Setup Performance record", excep);
}
}
else
{
e.Cancel = true;
this.datasetChangeover.RejectChanges();
//eventHandler.DisplayFatalError("deleteRow", "Unable to delete changeover record", excep);
}
}
}
catch (Exception ex)
{
eventHandler.DisplayFatalError("deleteRow", "Error deleting Setup Performance record", ex);
}
}

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

;