Dear Experts,
I have a datagridview in a 2013 vb.net winforms app.
I can get the value of a cell when identify it by column number but not by column name.
This works:
MyValue = DataGridView1.SelectedRows(0).Cells(18).Value
The following two samples do NOT work:
example one:
For Each col In DataGridView1.Columns
Debug.Print(col.Name)
Next
example two:
ecell = DataGridView1.CurrentRow.Index
DataGridView1.CurrentCell = DataGridView1.Item("d200", ecell)
MessageBox.Show(DataGridView1.CurrentCell.Value)
In first example it goes to 'next', doesn't loop, and never prints a column name.
In second example, it produces the error message: "column named d200 cannot be found"
I've tried this on several of its columns and get same error. The column name in database and column caption are identical.
Its as if it does not know its own column names!
Suggestions appreciated.
Thanks, Larry
Can you post the code which shows how you get the data from the database and how you populate the DataGridView.
Thanks;
Fernando