[Webinar] Streamline your web hosting managementRegister Today

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 279
  • Last Modified:

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!
0
dave_sky
Asked:
dave_sky
  • 2
1 Solution
 
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

Featured Post

The 14th Annual Expert Award Winners

The results are in! Meet the top members of our 2017 Expert Awards. Congratulations to all who qualified!

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now