collages
asked on
Adding a new row in an unbound DataGridView
I have a datagridview and i was hoping there was an easy method to create a new row based off of the datagridview.
for example:
Obviously gives me an instance of the row with the proper columns already bound to the row however if it's the first row in the DataGridView this will fire the SelectionChanged event.
I'm looking to get the exact same row with the proper columns already attached to it but not have it be added to the collection first so I can assign the proper values AND THEN attach it to the datagridview via the Rows.Add function.
I though this was posssible...
Thanks
for example:
DataGridViewRow dataGridViewRow = dataGridView.Rows[dataGridView.Rows.Add()];
Obviously gives me an instance of the row with the proper columns already bound to the row however if it's the first row in the DataGridView this will fire the SelectionChanged event.
I'm looking to get the exact same row with the proper columns already attached to it but not have it be added to the collection first so I can assign the proper values AND THEN attach it to the datagridview via the Rows.Add function.
I though this was posssible...
Thanks
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
DataRowView rowView = myView.AddNew();
// Change values in the DataRow.
rowView["ColumnName"] = "New value";
rowView.EndEdit();
then bind it to your dataGrid...