How to populate a bound datagridview column

Software: vb.net & sql server 2005

I need sample code to populate a bound datagridview column with values 1 thru 10 on form load.

Thanks!
dave_skyAsked:
Who is Participating?
 
Fernando SotoRetiredCommented:
Hi Dave;

You can use code like the following to do what you need.
'' The value to be inserted
Dim value As Integer = 1

'' Change the string "TheValue" to be the actual name of the column to be
'' pre-filled.
For i As Integer = 0 To DataGridView1.RowCount - 1
    DataGridView1.Rows(i).Cells("TheValue").Value = value.ToString()
    value += 1
Next

Open in new window

0
 
dave_skyAuthor Commented:
Thanks Fernando
0
 
Fernando SotoRetiredCommented:
Not a problem Dave, glad to help.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.