Quantcast
Channel: Windows Forms General forum
Viewing all articles
Browse latest Browse all 12583

How can we use a bound DataGridView to add new records?

$
0
0

Hello,

I'm using VS2010. I would like to allow users to add new records directly in the "new" row of a DataGridView, and to save to the database with clicking any buttons.

I'm using Entity Framework with ObjectContext. I have implemented IDataErrorInfo in the entities. I am also using a DataGridView which implements a CurrentRowChanged event.

The DataGridView is bound to a BindingSource whose datasource is generated from an entity in the model. I'll call the entity, "Employee".

Details aside, I can't find a good resource which explains simply and directly how to use a databound DataGridView to add new records. I'd like to know which properties should be set on the grid itself and which events I should handle to achieve my goal.

I'm not using a BindingNavigator, as I'd like to be able to fill in the required fields and allow RowValidating and RowValidated to handle the creation and saving of the new entity.

Thanks for any help.


Viewing all articles
Browse latest Browse all 12583

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>