?
Solved

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

Posted on 2013-10-27
5
Medium Priority
?
607 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 2000 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

Fill in the form and get your FREE NFR key NOW!

Veeam® is happy to provide a FREE NFR server license to certified engineers, trainers, and bloggers.  It allows for the non‑production use of Veeam Agent for Microsoft Windows. This license is valid for five workstations and two servers.

Question has a verified solution.

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

A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …

719 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