Hi .NET gurus,

How can I detect when user has just edited any cell in my datagrid so that I can set a dirty flag in my application ?

Any help is very much appreciated.

Thanks.

Kinh Luan

RE: Detect when datagrid is modified by ThorKornbrek

ThorKornbrek
Thu Jul 15 15:27:02 CDT 2004

One way is to create a derived DataGrid TextBox control.

Check this article out in the KnowlegeBase:

HOW TO: Extend the Windows Form DataGridTextBoxColumn Control to Custom-Format Data

Another way would be to use the CurrentCellChanged property of the DataGrid. The problem with that though is that only the current cell information is available. You can use this information and a couple of int variables to create a tracking mechanism.

If you need clarification let me know.

--
Thor Kornbrek
.Net Developer
http://www.thorknowsit.net


"Dotnetjunky" wrote:

> Hi .NET gurus,
>
> How can I detect when user has just edited any cell in my datagrid so that I can set a dirty flag in my application ?
>
> Any help is very much appreciated.
>
> Thanks.
>
> Kinh Luan

RE: Detect when datagrid is modified by SteveJensen

SteveJensen
Thu Sep 14 12:00:02 CDT 2006

The method I use to flag a change in the form data is to declare a form-level
variable:

dim bState as boolean = false


then in each of the following DataGridView event, put in bState = True
CurrentCellDirtyStateChanged 'catches changes to the data
RowsRemoved 'catches rows deleted
UserAddedRow 'catches new rows



"Thor Kornbrek" wrote:

> One way is to create a derived DataGrid TextBox control.
>
> Check this article out in the KnowlegeBase:
>
> HOW TO: Extend the Windows Form DataGridTextBoxColumn Control to Custom-Format Data
>
> Another way would be to use the CurrentCellChanged property of the DataGrid. The problem with that though is that only the current cell information is available. You can use this information and a couple of int variables to create a tracking mechanism.
>
> If you need clarification let me know.
>
> --
> Thor Kornbrek
> .Net Developer
> http://www.thorknowsit.net
>
>
> "Dotnetjunky" wrote:
>
> > Hi .NET gurus,
> >
> > How can I detect when user has just edited any cell in my datagrid so that I can set a dirty flag in my application ?
> >
> > Any help is very much appreciated.
> >
> > Thanks.
> >
> > Kinh Luan

RE: Detect when datagrid is modified by SteveJensen

SteveJensen
Thu Sep 14 13:32:01 CDT 2006

A side note on the earlier post - if you have your data adapter set to clear
before fill, the fill will trigger the RowsRemoved event, so be sure to set
your bState to False right after filling the adapter. Otherwise, your bState
will be set to True even if the user did not remove any rows.

"Thor Kornbrek" wrote:

> One way is to create a derived DataGrid TextBox control.
>
> Check this article out in the KnowlegeBase:
>
> HOW TO: Extend the Windows Form DataGridTextBoxColumn Control to Custom-Format Data
>
> Another way would be to use the CurrentCellChanged property of the DataGrid. The problem with that though is that only the current cell information is available. You can use this information and a couple of int variables to create a tracking mechanism.
>
> If you need clarification let me know.
>
> --
> Thor Kornbrek
> .Net Developer
> http://www.thorknowsit.net
>
>
> "Dotnetjunky" wrote:
>
> > Hi .NET gurus,
> >
> > How can I detect when user has just edited any cell in my datagrid so that I can set a dirty flag in my application ?
> >
> > Any help is very much appreciated.
> >
> > Thanks.
> >
> > Kinh Luan