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

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
vcharlesAsked:
Who is Participating?
 
adriankohwsCommented:
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
 
adriankohwsCommented:
Assuming that your datagridview has 4 columns already defined.


  Dim str As String() = {"BEL","CAN","FRA","USA"}
  dgdatagridview1.Rows.Add(Str)
0
 
vcharlesAuthor Commented:
I need to add the data in one column. Thanks.
0
 
vcharlesAuthor Commented:
Thank You.
0
 
adriankohwsCommented:
Great, so you figured out, I didn't add the comma in the Split parameter :)
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.