Addrow to DataGridView

T

Taoge

Hi, all

I want to add a row to a bound datagridview, suppose I need copy some
columns of a row from datagridview2 to datagridview1, the user select a row
in datagridview2, click a button, and then copy some columns of the selected
row to a new added row in datagridview1. Bur when I try to add a row in
datagridview1, the following exception throw:

Rows cannot be programmatically added to the DataGridView's rows collection
when the control is data-bound.

How can I add row to the DataGridView programmatically?

Thanks!
 
M

Mrinal

Hi ,

I think the idea out here is , since your control is databound , you need make relevant modification to the datasource
like dataset , array of whatever you are using and rebind on button click and that should solve the issue, by refreshing the
latest values to the control .

hope that helps ,

Mrinal
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top