Solved

How to populate a bound datagridview column

Posted on 2014-07-23
3
265 Views
Last Modified: 2014-07-24
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
Comment
Question by:dave_sky
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 63

Accepted Solution

by:
Fernando Soto earned 500 total points
ID: 40215334
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
 

Author Closing Comment

by:dave_sky
ID: 40215708
Thanks Fernando
0
 
LVL 63

Expert Comment

by:Fernando Soto
ID: 40216908
Not a problem Dave, glad to help.
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
how to just get time from a date 6 48
Need help with another query 10 36
Create a button class for use in all vb.net apps 5 14
Convert VB web project to C# 3 35
Wouldn’t it be nice if you could test whether an element is contained in an array by using a Contains method just like the one available on List objects? Wouldn’t it be good if you could write code like this? (CODE) In .NET 3.5, this is possible…
This article shows how to deploy dynamic backgrounds to computers depending on the aspect ratio of display
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial

763 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question