Solved

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

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

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

In my previous two articles we discussed Binary Serialization (http://www.experts-exchange.com/A_4362.html) and XML Serialization (http://www.experts-exchange.com/A_4425.html). In this article we will try to know more about SOAP (Simple Object Acces…
Creating an analog clock UserControl seems fairly straight forward.  It is, after all, essentially just a circle with several lines in it!  Two common approaches for rendering an analog clock typically involve either manually calculating points with…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

760 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

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now