Anyone know how to prevent people from deleting rows from a grid, but still allow them to select the cells and whatnot? I don’t want to set the grid to enabled because then they can’t even click things.
Setting it to read only still allowed a delete to happen.
I tried setting the grid.Override.AllowDelete = False, but that did not work.
I don’t want a BPM to stop the delete, because it needs to happen for that dataview in other areas.
For context, I want to prevent users from deleting rows from the Order Entry Summary tab, but allow it everywhere else.
//Class Level
Ice.Lib.Framework.EpiUltraGrid myGrid;
//Get a Hold of the GridOn the InitCustomCodeFunction
myGrid = csm.GetNativeControlReference("<GuidHere>");
grid.BeforeRowsDeleted += new Infragistics.Win.UltraWinGrid.BeforeRowsDeletedEventHandler(myGrid_BeforeRowsDeleted);
//Be a good citizen and destroy the handler in your Closing Function
grid.BeforeRowsDeleted -= new Infragistics.Win.UltraWinGrid.BeforeRowsDeletedEventHandler(myGrid_BeforeRowsDeleted);
//Declare your handler function and "jhandle" the delete event (AKA Cancel)
private void myGrid_BeforeRowsDeleted(object sender, Infragistics.Win.UltraWinGrid.BeforeRowsDeletedEventArgs args)
{
args.Cancel = true; //this "cancels" the delete event
}
Try seeing if you can stop it in the RowDeleting instead because after it comes RowDeleted
this.QuoteQty_Column.RowDeleting += new DataRowChangeEventHandler(this.QuoteQty_RowDeleting);
private void QuoteQty_RowDeleting(object sender, DataRowChangeEventArgs args)
{
if (QuoteQty_Column.Rows[modRowIndex].RowState.ToString() != "Deleted")
{
// Just a snippet from something else; conceptual try looking up the RowDeleting Event
}
}
You have it on QuoteQty_Column–does it matter which column is used?
I assume if the row is being deleted, that you could perform that check on any of the columns in the grid, right?
FYI I like you couldnt use the BeforeRow stuff so I used these 2 BUT I needed to detect if its deleted, not sure If you can prevent it I assume you can if its in RowDeleting.
this.QuoteQty_Column.RowDeleting += new DataRowChangeEventHandler(this.QuoteQty_RowDeleting);
this.QuoteQty_Column.RowDeleted += new DataRowChangeEventHandler(this.QuoteQty_RowDeleted);
I’m not so sure I can make that work since the Order Entry Summary grid and the Order Entry Line List grid both use the OrderDtl binding. It would be the same DataView.
I don’t want to prevent users from deleting from the line list view.
SO I got it to work but its a shitty hack and I don’t like it. Here if (YOU) implement it, that’s up to you LoL
I put a BeforeAdapterMethod event on the salesOrderAdapter
case “Delete” then I check to see if the grid has focus… if it does I “handle” it. however that does break the ability for someone to hit the Delete button on the toolbar while focused on the grid.