dotnetmonitor.com |
|
||||||||||||
| When the user
selects the row for new records as the current row, the DataGridView control
raises the DefaultValuesNeeded event. This event provides access to the new
DataGridViewRow and enables you to populate the new row with default data.
The following code example demonstrates how to specify default values for new rows using the DefaultValuesNeeded event. private void dataGridView1_DefaultValuesNeeded(object sender, DataGridViewRowEventArgs e) { e.Row.Cells["Region"].Value = "WA"; e.Row.Cells["City"].Value = "Redmond"; e.Row.Cells["PostalCode"].Value = "98052-6399"; e.Row.Cells["Region"].Value = "NA"; e.Row.Cells["Country"].Value = "USA"; e.Row.Cells["CustomerID"].Value = NewCustomerId(); } |
||||||||||||
|
||||||||||||