Hi Sean,
You could handle the appropriate changed event of the data source. In the
2.0 framework you could use a BindingSource component to wrap your data
source and handle the CurrentItemChanged event:
"BindingSource.CurrentItemChanged Event"
http://msdn2.microsoft.com/en-us/lib...emchanged.aspx
If you're binding directly to a DataTable or DataSet you can handle the
RowChanged event on the DataTable to which the grid is bound:
"DataTable.RowChanged Event"
http://msdn2.microsoft.com/en-us/lib...owchanged.aspx
If you're binding to a custom object or binding list you can implement your
own property changed event (although you can still use a BindingSource in
the 2.0 framework)
(Note: If you're using the 2.0 framework use the DataGridView control
instead of DataGrid, which is included in the VS 2005 Toolbox instead of
DataGrid anyway)
I recommend that you don't do this for a single cell, however. Instead,
think about updating the database after the current row loses focus and has
been validated. Also, the entire process is much easier using a
DataGridView. Simply handle the RowValidated event and perform the database
update there:
"DataGridView.RowValidated Event"
http://msdn2.microsoft.com/en-us/lib...ed(VS.80).aspx
You can tell whether a row has changes after it loses focus easily if you're
using a DataSet by checking the DataRow.RowState property for any value
other than
DataRowState.Unchanged and DataRowState.Detached.
"DataRow.RowState Property"
http://msdn2.microsoft.com/en-us/lib....rowstate.aspx
--
Dave Sexton
<se*****@gmail.comwrote in message
news:11*********************@73g2000cwn.googlegrou ps.com...
>I want to build a windows application that has a datagrid filled with
data. When a person modifies information on a single cell, it updates
the database without the user having to click on a save button.
Any ideas on how I can accomplish this?
Thanks,
Sean