Getting data from selected datagridview row and which event?

后端 未结 5 1368
眼角桃花
眼角桃花 2020-12-08 06:53

I have a DataGridView (Selectionmode: FullRowSelect) on a windows form along with some textboxes, so what i want to do is that whenever a user selects a row(click or double_

5条回答
  •  孤城傲影
    2020-12-08 07:08

    You can try this click event

    private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e)
    {
        if (e.RowIndex >= 0)
        {
            DataGridViewRow row = this.dataGridView1.Rows[e.RowIndex];
            Eid_txt.Text = row.Cells["Employee ID"].Value.ToString();
            Name_txt.Text = row.Cells["First Name"].Value.ToString();
            Surname_txt.Text = row.Cells["Last Name"].Value.ToString();
    

提交回复
热议问题