3 Replies - 4263 Views - Last Post: 03 October 2012 - 12:49 PM Rate Topic: -----

#1 clee06  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 66
  • Joined: 01-June 10

add row to datagridview

Posted 03 October 2012 - 12:19 PM

Could I possibly get something like this:

Dim temp_string As String = "1, John Doe, 22, 10-10-1990"
DataGridView1.Rows.Add(New Object() { temp_string})




...to work like this?

DataGridView1.Rows.Add(New Object() {ID, _
                                     Name, _
                                     Age, _
                                     Birthday})



Is This A Good Question/Topic? 0
  • +

Replies To: add row to datagridview

#2 _HAWK_  Icon User is offline

  • Master(Of Foo)
  • member icon

Reputation: 1067
  • View blog
  • Posts: 4,176
  • Joined: 02-July 08

Re: add row to datagridview

Posted 03 October 2012 - 12:31 PM

Make a class object that has those properties and then yes.
Was This Post Helpful? 1
  • +
  • -

#3 CharlieMay  Icon User is offline

  • This space intentionally left blank
  • member icon

Reputation: 1623
  • View blog
  • Posts: 5,200
  • Joined: 25-September 09

Re: add row to datagridview

Posted 03 October 2012 - 12:37 PM

You should also be able to do something like this:
Dim myArray() as String = {"1", "John Doe", "22", "10-10-1990"}
Datagridview1.Rows.Add(myArray)


With your current string, you could create your array by splitting on the comma

Dim temp_string As String = "1, John Doe, 22, 10-10-1990"
dim temp_Array() as string = temp_string.Split(","c)
DataGridView1.Rows.Add(temp_Array)



If I'm understanding you correctly.

This post has been edited by CharlieMay: 03 October 2012 - 12:41 PM

Was This Post Helpful? 0
  • +
  • -

#4 clee06  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 66
  • Joined: 01-June 10

Re: add row to datagridview

Posted 03 October 2012 - 12:49 PM

View PostCharlieMay, on 03 October 2012 - 12:37 PM, said:

You should also be able to do something like this:
Dim myArray() as String = {"1", "John Doe", "22", "10-10-1990"}
Datagridview1.Rows.Add(myArray)


With your current string, you could create your array by splitting on the comma

Dim temp_string As String = "1, John Doe, 22, 10-10-1990"
dim temp_Array() as string = temp_string.Split(","c)
DataGridView1.Rows.Add(temp_Array)



If I'm understanding you correctly.


thank you, this is exactly what i was looking for. at first, i wasn't sure if it takes array so i read the array to a string.

Datagridview1.Rows.Add(myArray)


Was This Post Helpful? 0
  • +
  • -

Page 1 of 1