5

By default the ultraWinGrid pops up a delete confirmation box for any row deletions. How do I turn that feature off?

If I'm deleting in the code, it's no problem:

myUltraGrid.DeleteSelectedRows(False)

But I don't know how to apply that when the user presses the delete key.

Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129
Jeff
  • 8,020
  • 34
  • 99
  • 157

5 Answers5

12

You can detect when they press the delete key on your row. Use something like the BeforeRowsDeleted event. That event exposes the BeforeRowsDeletedEventArgs object which has the e.DisplayPromptMsg property available to you.

private void ultraGrid_BeforeRowsDeleted(object sender, BeforeRowsDeletedEventArgs e)
{
     e.DisplayPromptMsg = false;
}
auujay
  • 578
  • 5
  • 19
1

How do you avoid a stack-overflow/endless loop? – Jeff 6 secs ago

auujay has it. It will not cause an endless loop because it only runs once no matter how many rows are selected and deleted. All this does is turn off the generic message box. We use it so we can display custom messages pre-delete like "Are you really, really sure?"

Use e.cancel=true if no.

rene
  • 41,474
  • 78
  • 114
  • 152
Brian Spencer
  • 194
  • 2
  • 7
0

There is a better way:

grid.DisplayLayout.Override.AllowDelete = DefaultableBoolean.False;
rene
  • 41,474
  • 78
  • 114
  • 152
VAAA
  • 14,531
  • 28
  • 130
  • 253
0

According to the documentation

UltraGridRow.Delete(false);
rene
  • 41,474
  • 78
  • 114
  • 152
Justin
  • 1
  • 2
0

The best solution is to use

UltraGridRow.Delete(displayPrompt As Boolean)

so

if you want the message : UltraGridRow.Delete(True)

if you dont want the message : UltraGridRow.Delete(False)