2 Replies - 357 Views - Last Post: 07 October 2012 - 01:21 AM Rate Topic: -----

#1 thantanenorn1  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 4
  • Joined: 06-October 12

Error in transferring textbox to DatagriView

Posted 06 October 2012 - 08:20 PM

Here's my Code (practice)

 Dim row As Integer = dgvCart.Rows.Count
        Dim tb As TextBox() = New TextBox() {txtShipAddress, txtBookName}
        dgvCart.Rows.Add()

        For i As Integer = 0 To tb.Length - 1
            dgvCart(i, row).Value = tb(0)

Next


The error is
"No row can be added to a DataGridView control that does not have columns. Columns must be added first."

Is This A Good Question/Topic? 0
  • +

Replies To: Error in transferring textbox to DatagriView

#2 trevster344  Icon User is offline

  • The Peasant
  • member icon

Reputation: 224
  • View blog
  • Posts: 1,501
  • Joined: 16-March 11

Re: Error in transferring textbox to DatagriView

Posted 06 October 2012 - 10:23 PM

Alright that's pretty straight forward. Declare some column objects there are a few, and add them to the datagridview control. Add some rows after, and then add some objects to those rows. One issue I see right there is that you're trying to place a control into a property. So I ask you what is the data type of the .Value property of the dgv row? ;)
Was This Post Helpful? 0
  • +
  • -

#3 thantanenorn1  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 4
  • Joined: 06-October 12

Re: Error in transferring textbox to DatagriView

Posted 07 October 2012 - 01:21 AM

String
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1