Hi!
I’m a new customer to this suite of tools, and have been working with the Grid on a single form all day. I have the grid bound to a dataset, and have successfully set up editing and adding of records. My problem rests with the deleting of rows from the grid (and, subsequently, records from the dataset).
The KB here says that the following code can be implemented in the KeyDown event of the DataRowTemplate object:
if( e.KeyData == Keys.Delete )
{
if( sender is DataRow )
{
( ( DataRow )sender ).Remove();
}
}
When I select the row, however, the sender is a DataCell, not a DataRow. I tried using the DataCell sender to obtain its parent row, and then removing that. Out of seven data rows, it works on only one or two – the remainder (even when the index of the data row is other than 5) gives me the following error:
“The index must be greater than or equal to 0 and less than Count.\r\nParameter name: index\r\nActual value was 5.”
This is frustrating – any ideas?
Imported from legacy forums. Posted by citb_ent_solns (had 1944 views)