Saving data in the DataGrid

  • Thread starter Thread starter Henrik Skak Pedersen
  • Start date Start date
H

Henrik Skak Pedersen

Hi,

I would like to save inserts, deletes and updates in the DataGridView bach
to the database when the user changes the current selected row. Right now I
am using the SelectionChanged event, but that fires everytime the user
changes column.

Is this really the only event I can use?

Thanks

Henrik Skak Pedersen
 
Hi Henrik,

How do y ou bind the DataGridView to the data source? Are you binding to a
DataSet directly, or binding to a BindingSource object?

If using a BindingSource, you can just handle the CurrentChanged or
PositionChanged event.

If you're binding to a DataSet object, please get the CurrencyManager and
handle the CurrentChanged or PositionChanged event of that CurrencyManager.

HTH.

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."
 
Hi Kevin,

Thank you very much. I will use the CurrentChanged event.

Thanks Henrik
 
You're welcome, Henrik.

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."
 
Hi guys,
I have a follow up question I'm hoping you can help me with. Like
Henrik, I would like to save records back to the database when I change
rows but I want to perform some validation before I save the record.
If the validation fails I want to keep the user on the row in error,
but you can't cancel the row changing event so the user is always moved
to the new row. I've put in both row changing and column changing
events but still have the problem.

Any suggestions would be appreciated.

Thanks,
Kelly Pearson
 
Hi Kevin,

I am facing some problems while working with Datagrid in my windows form
using c#.
I want my grid as Read only. But on a certain condition (let's say on button
click) I want to make it Updatable, but at a time only one row shold be
updatable.
How can I achieve this.

Thanks in advance.
Shailesh
 
Back
Top