Populating data in a form
-
Im am developing a windows app, and i have data populated into a gridview. Instead of allowing users to edit the data in the grid(which is probably the easiest way) I want to be able to select a row and have a modal form pop up with Textboxes and other controls to edit the data. How would i go about populating data in those controls from with the information of with the gridview?
-
Im am developing a windows app, and i have data populated into a gridview. Instead of allowing users to edit the data in the grid(which is probably the easiest way) I want to be able to select a row and have a modal form pop up with Textboxes and other controls to edit the data. How would i go about populating data in those controls from with the information of with the gridview?
Add a Column/Link button to the row, handle the cell content click event and pass a reference to the row data to the new form:
private void dgv_CellContentClick(object sender, DataGridViewCellEventArgs e) { DataGridView dgv = sender as DataGridView; if (dgv.Columns[e.ColumnIndex] is DataGridViewButtonColumn) { DataForm df = new DataForm(dgv.Rows[e.RowIndex]); df.ShowDialog(); } }
I think that should do it! -- modified at 17:33 Wednesday 18th July, 2007