Solved

Help with displaying data from string variable in a DataGrid using VB.NET

Posted on 2013-10-27
5
601 Views
Last Modified: 2013-10-27
Hi,

If I  have a string variable S = BEL,CAN,FRA,USA

How do I display the values in a DataGrid as shown below? My string will vary, just using values in S as an example.

BEL
CAN
FRA
USA

Thanks,

Victor
0
Comment
Question by:vcharles
[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
  • 3
  • 2
5 Comments
 
LVL 10

Expert Comment

by:adriankohws
ID: 39603768
Assuming that your datagridview has 4 columns already defined.


  Dim str As String() = {"BEL","CAN","FRA","USA"}
  dgdatagridview1.Rows.Add(Str)
0
 

Author Comment

by:vcharles
ID: 39603780
I need to add the data in one column. Thanks.
0
 
LVL 10

Accepted Solution

by:
adriankohws earned 500 total points
ID: 39603792
Dim eStr As String = "BEL","CAN","FRA","USA"
Dim str() As String
str = eStr.Split(" ")
For Each s As String In str
    dgdatagridview1.Rows.Add(s)
Next

Assuming you have one column in datagridview
0
 

Author Closing Comment

by:vcharles
ID: 39603821
Thank You.
0
 
LVL 10

Expert Comment

by:adriankohws
ID: 39603826
Great, so you figured out, I didn't add the comma in the Split parameter :)
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

More often than not, we developers are confronted with a need: a need to make some kind of magic happen via code. Whether it is for a client, for the boss, or for our own personal projects, the need must be satisfied. Most of the time, the Framework…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

761 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