2 Replies - 794 Views - Last Post: 20 February 2013 - 11:14 AM Rate Topic: -----

#1 alobi  Icon User is offline

  • D.I.C Head

Reputation: 1
  • View blog
  • Posts: 178
  • Joined: 21-January 13

Datagridview click event

Posted 20 February 2013 - 10:31 AM

I put a click even on the datagridview. Im tryin to get the content of this grid to load some textboxes on a second form. But I kept getting error message,
    Private Sub DataGridView1_CellContentClick(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles DataGridViewCheckEmployee.CellContentClick
        frmNewEmployee.Show()
        Me.Hide()
        frmNewEmployee.txtSureName.Text = DataGridViewCheckEmployee.Rows(e.RowIndex).Cells(1).text
        frmNewEmployee.TxtFirstName.Text = DataGridViewCheckEmployee.Rows(e.RowIndex).Cells(2).Text
        frmNewEmployee.TxtMiddleName.Text = DataGridViewCheckEmployee.Rows(e.RowIndex).Cells(2).Text
        frmNewEmployee.TxtFirstName.Text = DataGridViewCheckEmployee.Rows(e.RowIndex).Cells(2).Text
    End Sub


ERRORs
Error 1 'text' is not a member of 'System.Windows.Forms.DataGridViewCell'.
Error 2 'Text' is not a member of 'System.Windows.Forms.DataGridViewCell'.
Error 3 'Text' is not a member of 'System.Windows.Forms.DataGridViewCell'.
Error 4 'Text' is not a member of 'System.Windows.Forms.DataGridViewCell'.

Is This A Good Question/Topic? 0
  • +

Replies To: Datagridview click event

#2 macosxnerd101  Icon User is online

  • Games, Graphs, and Auctions
  • member icon




Reputation: 12298
  • View blog
  • Posts: 45,399
  • Joined: 27-December 08

Re: Datagridview click event

Posted 20 February 2013 - 10:34 AM

Moved to VB.NET. Please don't post help questions in the challenges subforum.
Was This Post Helpful? 0
  • +
  • -

#3 _HAWK_  Icon User is offline

  • Master(Of Foo)
  • member icon

Reputation: 1162
  • View blog
  • Posts: 4,444
  • Joined: 02-July 08

Re: Datagridview click event

Posted 20 February 2013 - 11:14 AM

Calling .Value on a cell will give the contents. As the error states there is no .Text member on a cell. I recommend opening a new instance of that form instead of the default instance. Then pass the cell info to it - better code practice. DataGridViewCell

This post has been edited by _HAWK_: 20 February 2013 - 11:16 AM

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1