How do Disable Delete button over DataGrid

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

hi all,

i have an applicaiton in which i am using datagrid its working properly, the
problem here is if i select a row and press "Delete" Key (Key board) the row
is getting deleted. how to prevent this?? what property of Datagird i need to
set to prevent this deletion.

Thanks
San :)
 
Hi San,

Try capturing the keydown event and check if the delete was pressed. I
didn't try it because I'm running out, but I assume it will work. Let me
know how it turns out.

private void dataGrid1_KeyDown(object sender,
System.Windows.Forms.KeyEventArgs e) {

if (e.KeyCode == Keys.Delete) {
return;
}
}




--
Tom Krueger

My Blog - http://weblogs.asp.net/tom_krueger
Smart Client DevCenter - http://msdn.microsoft.com/smartclient/
Mobile DevCenter - http://msdn.microsoft.com/mobility

This posting is provided "as is" with no warranties and confers no rights.
 
Try setting your datagrid.DataSource to a DataView and set the
DataView.AllowDelete properity to false.

Regards
 
Back
Top