473,408 Members | 2,832 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,408 software developers and data experts.

Add array to DataGridView VB.NET 2005

5
So I've got an array of string values which I'd like to display in an unbound DataGridView. What is the process necessary to simply load strings into cells of a datagrid?

Ideally, we would go from this:

strArray(0) = "Ralph"
strArray(1) = "Johnston"
strArray(2) = "12/15/87"

to this (forgive the crude drawing):

| Ralph | Johnston | 12/15/87 |


I've had success getting values in with the code below, but this adds a new column onto the datagrid. What I want is to add data values into and existing column structure that I have in place. Thanks for your time.

Expand|Select|Wrap|Line Numbers
  1. Dim strArray() As String = {"Ralph"}
  2. Dim dt As New DataTable
  3. dt.Columns.Add("FirstName", GetType(String))
  4. Dim dr As DataRow = dt.NewRow
  5. dr("FileName") = strArray(0)
  6. dt.Rows.Add(dr)
  7. ' Set the datagrid's source
  8. Me.dgMain.DataSource = dt
  9.  
Jun 11 '08 #1
1 4575
Plater
7,872 Expert 4TB
You can manipulate the DataGridView items themselves (provided it is unbound)

Expand|Select|Wrap|Line Numbers
  1. int myRowIdx=myDataGridView.Rows.Add();
  2. DataGridViewRow dgr = myDataGridView.Rows[myRowIdx];
  3. dgr.Cells["MyColumnName"].Value = "Some value";
  4.  
Jun 11 '08 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Arvind | last post by:
Hi I edit a cell in a DataGridView, and then would move to another cell in the DataGridView using mouse. Then the DataGridView as of now does scroll down to the last visited cell. But when I try...
6
by: dbuchanan | last post by:
Hello, Is this a bug? Is there some kind of work around? I want to add default values for a few columns in my datagridview I found the "DefaultValuesNeeded" event for the datagridview I...
4
by: dm1608 | last post by:
Hello, I have a DataGridView control in VB.NET 2005 that I would like to iterate thru row by row and parse out the individual columns into variables. Can someone provide me example code or direct...
1
by: ME | last post by:
I was running into a problem with the DataGridView while binding it to an object Collection. I got it working and I thought others might like to know how. -------------- Problem -------------...
3
by: Daniel Manes | last post by:
I need a strategy to debug this situation... I can't put all the code involved, but here are some of the critical lines with comments: ------------------------- Private _parentDataCell As...
0
by: Mark Jerde | last post by:
VS 2005 SP1. Googled without success. I have an array of structs, and some of the elements are arrays of structs. E.g., ------------------------------------- public struct foobar { public int...
1
by: Karl | last post by:
Hi all... This is a good one. You'll like this... I am working on a course management tool that allows certain Courses to be cross referenced with Job Roles and, when they are, whether the...
3
by: =?Utf-8?B?UGV0ZXI=?= | last post by:
I'm trying to add a datagridview control to a Windows Form to display read-only information in visual basic 2005. My understanding is that datareader will be faster for this purpose. I have the...
0
by: priyamtheone | last post by:
I'm trying to make a datagridview column to act like a datetimepicker column (C#.Net 2005). These are the behaviours that the dgv should have: 1) Initially all the cells of the dtp column should be...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.