How do Disable Delete button over DataGrid

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 :)
 
T

Tom Krueger [MSFT]

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.
 
G

Guest

Try setting your datagrid.DataSource to a DataView and set the
DataView.AllowDelete properity to false.

Regards
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top