VB.Net’s DataGridView supports naming columns, but I was wondering if it could somehow do the same for rows, so that we could use something like this:
With DataGridView1
.Rows.Add(4)
.Rows(0).Name = "Setting1"
.Rows(1).Name = "Setting2"
'Added two columns at design time
.Columns("Key").Row("Setting1") = "Key1"
.Columns("Value").Row("Setting1") = "Value1"
.Columns("Key").Row("Setting2") = "Key2"
.Columns("Value").Row("Setting2") = "Value2"
End With
Do you confirm that it’s not possible and we must use numeric indexes to refer to row numbers?
There is no
Nameproperty onDataGridViewRow, so no, it’s not possible.You could always use a
Dictionaryto tie a name to aDataGridViewRow: