Tavousi
Tavousi

Reputation: 15446

How can I add one row to a DataGridView?

I work with a WinForms app. I want to add one row to a DataGridView that this row must enter to database. What event handler must I use to do this?

Upvotes: 0

Views: 1400

Answers (2)

Markus Schwalbe
Markus Schwalbe

Reputation: 123

This might help you out to add a row to the DataGridView: http://msdn.microsoft.com/de-de/library/system.windows.forms.datagridview%28v=vs.80%29.aspx

If the DataGridView isn't bound to the database, try to bound it or write the data to the database programmatically.

Upvotes: 0

Cody Gray
Cody Gray

Reputation: 244732

Is your DataGridView bound to that database? If so, you should be adding and deleting rows in that data source, not in the grid control itself. Try calling the AddNew method on the binding source.

If you're using a standalone DataGridView that isn't bound to a database, then you can call one of the many overloads of the Add method of the grid control's Rows collection.

Upvotes: 1

Related Questions