# Prevent Grid Delete

**URL:** <https://www.epiusers.help/t/prevent-grid-delete/45596>\
**Category:** Epicor ERP 10\
**Created:** [June 22, 2018, 1:35pm UTC](https://www.epiusers.help/t/prevent-grid-delete/45596 "2018-06-22T13:35:02Z")\
**Posts on this page:** 15\
**Page:** 1

<div class="post-metadata">

**Author:** ![hmwillett](https://www.epiusers.help/user_avatar/www.epiusers.help/hmwillett/32/93207_2.png) [@hmwillett](https://www.epiusers.help/u/hmwillett)\
**Post date:** [June 22, 2018, 1:35pm UTC](https://www.epiusers.help/t/prevent-grid-delete/45596/1 "2018-06-22T13:35:02Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![josecgomez](https://www.epiusers.help/user_avatar/www.epiusers.help/josecgomez/32/55731_2.png) [@josecgomez](https://www.epiusers.help/u/josecgomez)\
**Post date:** [June 22, 2018, 1:46pm UTC](https://www.epiusers.help/t/prevent-grid-delete/45596/2 "2018-06-22T13:46:43Z")

</div>

Sure thing pretty easy actually.

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

```

---

<div class="post-metadata">

**Author:** ![hmwillett](https://www.epiusers.help/user_avatar/www.epiusers.help/hmwillett/32/93207_2.png) [@hmwillett](https://www.epiusers.help/u/hmwillett)\
**Post date:** [June 22, 2018, 1:48pm UTC](https://www.epiusers.help/t/prevent-grid-delete/45596/3 "2018-06-22T13:48:24Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![josecgomez](https://www.epiusers.help/user_avatar/www.epiusers.help/josecgomez/32/55731_2.png) [@josecgomez](https://www.epiusers.help/u/josecgomez)\
**Post date:** [June 22, 2018, 1:51pm UTC](https://www.epiusers.help/t/prevent-grid-delete/45596/4 "2018-06-22T13:51:07Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![hkeric.wci](https://www.epiusers.help/user_avatar/www.epiusers.help/hkeric.wci/32/52019_2.png) [@hkeric.wci](https://www.epiusers.help/u/hkeric.wci)\
**Post date:** [June 22, 2018, 2:05pm UTC](https://www.epiusers.help/t/prevent-grid-delete/45596/5 "2018-06-22T14:05:41Z")

</div>

Try seeing if you can stop it in the RowDeleting instead because after it comes RowDeleted

```auto
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
		}
}

```

---

<div class="post-metadata">

**Author:** ![hmwillett](https://www.epiusers.help/user_avatar/www.epiusers.help/hmwillett/32/93207_2.png) [@hmwillett](https://www.epiusers.help/u/hmwillett)\
**Post date:** [June 22, 2018, 3:51pm UTC](https://www.epiusers.help/t/prevent-grid-delete/45596/6 "2018-06-22T15:51:08Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![hkeric.wci](https://www.epiusers.help/user_avatar/www.epiusers.help/hkeric.wci/32/52019_2.png) [@hkeric.wci](https://www.epiusers.help/u/hkeric.wci)\
**Post date:** [June 22, 2018, 5:01pm UTC](https://www.epiusers.help/t/prevent-grid-delete/45596/7 "2018-06-22T17:01:10Z")

</div>

Actually I think QuoteQty\_Clumn is just Epicors EpiDataView or DataRow isnt even the column 🙂

> this.QuoteQty\_Column.ColumnChanged += new DataColumnChangeEventHandler(this.QuoteQty\_AfterFieldChange);

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

---

<div class="post-metadata">

**Author:** ![josecgomez](https://www.epiusers.help/user_avatar/www.epiusers.help/josecgomez/32/55731_2.png) [@josecgomez](https://www.epiusers.help/u/josecgomez)\
**Post date:** [June 22, 2018, 5:02pm UTC](https://www.epiusers.help/t/prevent-grid-delete/45596/8 "2018-06-22T17:02:30Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![hkeric.wci](https://www.epiusers.help/user_avatar/www.epiusers.help/hkeric.wci/32/52019_2.png) [@hkeric.wci](https://www.epiusers.help/u/hkeric.wci)\
**Post date:** [June 22, 2018, 5:02pm UTC](https://www.epiusers.help/t/prevent-grid-delete/45596/9 "2018-06-22T17:02:59Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![hkeric.wci](https://www.epiusers.help/user_avatar/www.epiusers.help/hkeric.wci/32/52019_2.png) [@hkeric.wci](https://www.epiusers.help/u/hkeric.wci)\
**Post date:** [June 22, 2018, 5:07pm UTC](https://www.epiusers.help/t/prevent-grid-delete/45596/10 "2018-06-22T17:07:13Z")

</div>

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.

```auto
this.QuoteQty_Column.RowDeleting += new DataRowChangeEventHandler(this.QuoteQty_RowDeleting);
this.QuoteQty_Column.RowDeleted += new DataRowChangeEventHandler(this.QuoteQty_RowDeleted);

```

---

<div class="post-metadata">

**Author:** ![hmwillett](https://www.epiusers.help/user_avatar/www.epiusers.help/hmwillett/32/93207_2.png) [@hmwillett](https://www.epiusers.help/u/hmwillett)\
**Post date:** [June 22, 2018, 5:40pm UTC](https://www.epiusers.help/t/prevent-grid-delete/45596/11 "2018-06-22T17:40:09Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![josecgomez](https://www.epiusers.help/user_avatar/www.epiusers.help/josecgomez/32/55731_2.png) [@josecgomez](https://www.epiusers.help/u/josecgomez)\
**Post date:** [June 22, 2018, 5:47pm UTC](https://www.epiusers.help/t/prevent-grid-delete/45596/12 "2018-06-22T17:47:57Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![hmwillett](https://www.epiusers.help/user_avatar/www.epiusers.help/hmwillett/32/93207_2.png) [@hmwillett](https://www.epiusers.help/u/hmwillett)\
**Post date:** [June 22, 2018, 5:58pm UTC](https://www.epiusers.help/t/prevent-grid-delete/45596/13 "2018-06-22T17:58:08Z")

</div>

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.

 ![image](https://epiusers.help/uploads/default/original/2X/8/8ed06357b9c55f4f93cfc687f723083277d1a61b.jpg)

---

<div class="post-metadata">

**Author:** ![josecgomez](https://www.epiusers.help/user_avatar/www.epiusers.help/josecgomez/32/55731_2.png) [@josecgomez](https://www.epiusers.help/u/josecgomez)\
**Post date:** [June 22, 2018, 5:59pm UTC](https://www.epiusers.help/t/prevent-grid-delete/45596/14 "2018-06-22T17:59:16Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![hmwillett](https://www.epiusers.help/user_avatar/www.epiusers.help/hmwillett/32/93207_2.png) [@hmwillett](https://www.epiusers.help/u/hmwillett)\
**Post date:** [June 22, 2018, 5:59pm UTC](https://www.epiusers.help/t/prevent-grid-delete/45596/15 "2018-06-22T17:59:54Z")

</div>

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
