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]
$100 per TB is disgusting especially when we have advanced so much in this area, it's because RAM, Flash memory costs so much that creating a small factor, lots of space drives are just through the roof in material requirements.
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
https://www.neowin.net/forum/topic/1141922-c-datagridview-values-giving-error-when-trying-to-open-a-form/Share on other sites
2 answers to this question
Recommended Posts