VB code

    Private Sub DataGridView1_CellMouseClick(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DataGridViewCellMouseEventArgs) Handles DataGridView1.CellMouseClick
        Me.Text = click_count
        click_count = click_count + 1

        Try
            If click_count = 1 Then
                ' dd1.Text = DataGridView1.CurrentCell.Value.ToString
                dd1.Text = DataGridView1.CurrentRow.Cells(1).Value.ToString
            End If

            If click_count = 2 Then
                'dd2.Text = DataGridView1.CurrentCell.Value.ToString
                dd2.Text = DataGridView1.CurrentRow.Cells(1).Value.ToString
                click_count = 0
            End If

        Catch ex As Exception
            MessageBox.Show("GGGGGGGGGGG")
        End Try

    End Sub

 



C#code

private void dgvData_CellMouseClick(object sender, DataGridViewCellMouseEventArgs e)
{
   //取得目前滑鼠點選的CELL值
   //textBox2.Text = dgvData.CurrentCell.Value.ToString();
   //取得目前滑鼠點選的ROW值
   textBox2.Text = dgvData.CurrentRow.Cells[1].Value.ToString();
   textBox3.Text = dgvData.CurrentRow.Cells[2].Value.ToString();
   textBox4.Text = dgvData.CurrentRow.Cells[3].Value.ToString();

}
arrow
arrow
    文章標籤
    DataGridView textbox1 第幾行
    全站熱搜

    JL8051 發表在 痞客邦 留言(0) 人氣()