Solved

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

Posted on 2013-10-27
5
602 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

Today I had a very interesting conundrum that had to get solved quickly. Needless to say, it wasn't resolved quickly because when we needed it we were very rushed, but as soon as the conference call was over and I took a step back I saw the correct …
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…
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…

734 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