DataGrid: Update datasource when closing form

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

Guest

Hi,

The situation is the following: A user is editing a cell in a DataGrid, and
hasn't pressed <return> or <enter>, so the value is being edited. The user
then closes the form. I would like to update the value to the data source if
it is valid, or prevent closing the form if the edited value is invalid.

Actually, all I need for this to accomplish are the following two functions:
(1) A function that tells me whether or not the user is actually editing a
cell's contents.
(2) A function that tries to end the edit operation, and returns whether
ending the operation succeeded. Ending the edit operation should fail if the
value being edited is invalid (not valid).

I haven't found these yet.
About (1): I've checked DataRowView's IsEdit member, but I tested it and it
seems to return true even if a user isn't editing a cell in that row.
About (2) DataGrid has an EditEdit method. Sadly it returns false when no
cell is being edited, so I can't make the distinction between an invalid
entry or the fact that the cell isn't being edited. So using (2) alone
doesn't work.

Thanks for any help
 
Small typo, see below

TT (Tom Tempelaere) said:
Hi,

The situation is the following: A user is editing a cell in a DataGrid, and
hasn't pressed <return> or <enter>, so the value is being edited. The user
then closes the form. I would like to update the value to the data source if
it is valid, or prevent closing the form if the edited value is invalid.

Actually, all I need for this to accomplish are the following two functions:
(1) A function that tells me whether or not the user is actually editing a
cell's contents.
(2) A function that tries to end the edit operation, and returns whether
ending the operation succeeded. Ending the edit operation should fail if the
value being edited is invalid (not valid).

I haven't found these yet.
About (1): I've checked DataRowView's IsEdit member, but I tested it and it
seems to return true even if a user isn't editing a cell in that row.
About (2) DataGrid has an EditEdit method. Sadly it returns false when no

Of course I meant EndEdit, not EditEdit.
 
Back
Top