Prevent Grid Delete

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.

Sure thing pretty easy actually.

//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
		
	}

Hmmm, I had tried that as well and it did not seem to prevent the deletion.

Meh, Epicor must be intercepting that early… that’s annoying.

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?

Actually I think QuoteQty_Clumn is just Epicors EpiDataView or DataRow isnt even the column :slight_smile:

this.QuoteQty_Column.ColumnChanged += new DataColumnChangeEventHandler(this.QuoteQty_AfterFieldChange);

Its just what the Wizard use for AfterFieldChange - cant think of it now =)

QuoteQty_Column is an alias (variable) for the adapter.Table[“QuoteQty”] why did they call it QuoteQty_Column… cause fun!

Its part of the Show All Code of Quote Entry :slight_smile: good question lol thats what the Wizards use in Quote Entry.

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.

Well, it works, lol.
I like how it almost gives you the satisfaction of the deleting the line, but at the very last moment, NOPE.

So u implemented my hack? #Shameful … but when it works it works…

I wouldn’t say implemented quite yet.
I put it in test. I’ll let the users decide if that’s satisfactory or not. #NotMyProblem =P