Specify which datagridview column to put into
Hello
I am having some trouble with a datagridview in my program
i am using this command to add some items to my columns in the datagridview
Code:
datagridview1.Rows.Insert(0, .Item(0), .Item(1))
BUT i have 10+ columns and, lets say i wanted to add something to column 4 and not 1 and 2 as i do in the code above
I have tried this, but this just leaves the first columns blank which doesnt work for me.
Code:
datagridview1.Rows.Insert(0, "", "", .Item(0), .Item(1))
With that code i can put my items into column 3 and 4, but this also erases whats already in column 1 and 2
Any help?
Re: Specify which datagridview column to put into
You can insert data by cell coordinate, e.g. assuming the row already exists;
DataGridView1.Rows(5).Cells(3).Value = "Hello"
Re: Specify which datagridview column to put into
Here is one method.
Code:
Dim row As New DataGridViewRow
row.CreateCells(DataGridView1)
row.Cells(4).Value = "something"
DataGridView1.Rows.Insert(0, row)