Results 1 to 2 of 2

Thread: VB.NET datagridview Click event Error message

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Dec 2007
    Posts
    204

    VB.NET datagridview Click event Error message

    I put a click event 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,

    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'.
    Code:
        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(3).Text
            frmNewEmployee.TxtFirstName.Text = DataGridViewCheckEmployee.Rows(e.RowIndex).Cells(4).Text
        End Sub

  2. #2
    PowerPoster stanav's Avatar
    Join Date
    Jul 2006
    Location
    Providence, RI - USA
    Posts
    9,289

    Re: VB.NET datagridview Click event Error message

    A datagridviewcell has a value. The value is of Object type, so you need to convert that to string.
    Code:
    frmNewEmployee.txtSureName.Text = DataGridViewCheckEmployee.Rows(e.RowIndex).Cells(1).Value.ToString
    Do the same for the other 3 lines and it should clear the error.
    Let us have faith that right makes might, and in that faith, let us, to the end, dare to do our duty as we understand it.
    - Abraham Lincoln -

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width