The concept is simple. The user selects a row and clicks "Edit", opens the form and all the data from the row is in the perspective fields on the edit form.
I've had no problem doing this method with a ListView using SelectedItems[0].Tag, but working with a DataGridView now and I get a object reference error.
How doe I get the values of the cells to populate "part"?
The datagridview is in full row select, multiselect false.
private void EditPart() { PartData part; // Ignore if no row is selected if (DgParts.SelectedRows.Count == 0) { return; } try { // Is not tagging data at all. part = (PartData)DgParts.SelectedRows[0].Tag;
// Open Form with Data var edit = new FrmPartsAddEdit(this, "Edit", part); // Commit if OK if (edit.ShowDialog() == DialogResult.OK) { part = edit.GetPart(); // DB Stuff } } [/CODE]
Question
Kalint
The concept is simple. The user selects a row and clicks "Edit", opens the form and all the data from the row is in the perspective fields on the edit form.
I've had no problem doing this method with a ListView using SelectedItems[0].Tag, but working with a DataGridView now and I get a object reference error.
How doe I get the values of the cells to populate "part"?
The datagridview is in full row select, multiselect false.
Thaaaaaaanks!
Link to comment
Share on other sites
2 answers to this question
Recommended Posts