title: display datagridview cell data in the textbox in vb.net
body: <p>i want to display my datagridview1 data in relevant textboxes. when i select any cell in the datagridview1 relevant data should be displayed in textboxes. 
  here is the code i did</p>
  
  <pre><code>Private Sub DataGridView1_CellClick(ByVal sender As Object, _
   ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) _
   Handles DataGridView1.CellClick
  
  
      Dim i As Integer
      i = DataGridView1.CurrentRow.Index
      Me.Label8.Text = DataGridView1.Item(0, i).Value
      Me.TextBox1.Text = DataGridView1.Item(1, i).Value
      Me.TextBox2.Text = DataGridView1.Item(2, i).Value
      Me.ComboBox1.Text = DataGridView1.Item(3, i).Value
      Me.ComboBox2.Text = DataGridView1.Item(4, i).Value
      Me.TextBox5.Text = DataGridView1.Item(5, i).Value
      Me.TextBox3.Text = DataGridView1.Item(6, i).Value
      Me.TextBox4.Text = DataGridView1.Item(7, i).Value
      Me.RichTextBox1.Text = DataGridView1.Item(8, i).Value
      Me.RichTextBox2.Text = DataGridView1.Item(9, i).Value
      Me.Label14.Text = DataGridView1.Item(10, i).Value
  End Sub
  </code></pre>
  
  <p>i did another code here it is</p>
  
  <pre><code>Private Sub DataGridView1_CellContentClick(ByVal sender _
                             As System.Object, ByVal e As _
          System.Windows.Forms.DataGridViewCellEventArgs) _
                   Handles DataGridView1.CellContentClick
  
     Try
          If e.RowIndex &gt;= 0 Then
              Dim row As DataGridViewRow
              row = Me.DataGridView1.Rows(e.RowIndex)
              Label8.Text = row.Cells("id").Value.ToString
              TextBox1.Text = row.Cells("firstname").Value.ToString
              TextBox2.Text = row.Cells("lastname").Value.ToString
              ComboBox1.Text = row.Cells("year").Value.ToString
              ComboBox2.Text = row.Cells("month").Value.ToString
              TextBox5.Text = row.Cells("gender").Value.ToString
              TextBox3.Text = row.Cells("address").Value.ToString
              TextBox4.Text = row.Cells("telephone").Value.ToString
          End If
  
      Catch ex As Exception
          MessageBox.Show(ex.Message)
      End Try
  </code></pre>
  
  <p>however both codes are not working they give errors. inside the "" marks represent the column name</p>
  
  <p>can anyone give me the solution in vb.net</p>