I'm creating a Windows Forms 2.0 app in Visual Studio 2008. The form has a DataGridView control which will have rows programmatically added to it with the overload Add(ByVal ParamArray Values())
, as shown:
dgv.Rows.Add (var1, var2, var3, varEtc)
Is there a way to refer to the cells by name rather than by relying on their order..?
The dgv will have many columns, and referring to them by order will be confusing as I develop the app. It would be much easier to refer to them by some name or index string.
Unfortunately the DataGridView classes are many and vast, and I don't know which direction to go in. I have a half-baked idea to create each row object first, configure it, and and then add it to the collection, as shown below:
Dim dgvr as DataGridViewRow = New DataGridViewRow
...more code needed...
dgvr.SomeProp.ID = var1
dgvr.SomeProp.NameF = var2
dgvr.SomeProp.NameL = var3
dgvr.SomeProp.Etc = varEtc
dgv.Rows.Add (dgvr)
I'm sure this isn't the only way, and not yet even a functional one. Can I make this work..? What other ways are there..? Anything better..?