Home Forums WinForms controls Xceed Grid for WinForms Problem with grid deleting rows

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • User (Old forums)
    Member
    Post count: 23064
    #14466 |

    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)

    User (Old forums)
    Member
    Post count: 23064

    I was not able to reproduce this issue, the row was deleted properly. Can you tell me the version of your Xceed.Grid.Dll? Also, can you show me how you add your rows? Are you dataBound? As for the sender, when I trace it did give me DataRow, are you sure you are subscribing on the right object?

    Imported from legacy forums. Posted by Matt (had 2977 views)

Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.