Hi guys,
I'm just starting to covert over to VB.NET2005 (had been in the dark ages using VB6 until now), and although it is strange to me in a few ways I am getting used to it and liking .net more and more...
One problem I am having though, is I am using and unbound DataGridView that I am setting up in-code rather than through the gui, which is all fine and working great, but I am having problems when creating new rows. I have figured out how to do this in two ways,
Firstly I can go
dgv.Rows.Add()
dvb..Rows(dgv.Rows.Count()).Cells("blah").Value = "blah!"
Secondly (and the way I want to do it) I can go
Dim dgvr As New DataGridViewRow
dgvr.CreateCells(dgv)
dgvr.Cells(0).Value = "Blah"
dgvr.Cells(1).Value = "Blah Blah"
dgv.rows.add(dgvr)
My problem/question is, I currently have to refer to the cells by number (ie: dgvr.cells(0).va...), but I would much prefer to refer to them by name like I do when i add teh row then mess with it as in the first example - I find using the names will lead to less confusion and neater, more self-documenting code... But why doesnt it work?
When I try to do this, and run the app, i get an 'ArgumentExeption was unhandled'...'Column name Blah could not be found' error (and yes, i have checked that i am using the correct name for the cell).
Is it that when the row gets created it doesnt create the cells with the same names as the columns?... I dunno...
If anyone out there knows how to do this please let me know
Thanks in advance and i appologise for the long post