1. Add datagridview from toolbox into windowsform.
2. Now populate datagridview by your required data. I already have populated my datagridview.
3. Now add fields like lables and textboxes alongside datagridview like shown below:
4. Now write the following code in the click event of datagridview.
CODE:
private void dataGridView1_Click(object sender, EventArgs e)
{
try
{
for (int i = 0; i < dataGridView1.Columns.Count; i++)
{
textBox5.Text = this.dataGridView1.CurrentRow.Cells[0].Value.ToString();
textBox6.Text = this.dataGridView1.CurrentRow.Cells[1].Value.ToString();
textBox7.Text = this.dataGridView1.CurrentRow.Cells[2].Value.ToString();
textBox8.Text = this.dataGridView1.CurrentRow.Cells[3].Value.ToString();
textBox9.Text = this.dataGridView1.CurrentRow.Cells[4].Value.ToString();
textBox10.Text = this.dataGridView1.CurrentRow.Cells[5].Value.ToString();
textBox11.Text = this.dataGridView1.CurrentRow.Cells[6].Value.ToString();
textBox12.Text = this.dataGridView1.CurrentRow.Cells[7].Value.ToString();
textBox13.Text = this.dataGridView1.CurrentRow.Cells[8].Value.ToString();
textBox14.Text = this.dataGridView1.CurrentRow.Cells[8].Value.ToString();
textBox5.Focus();
}
}
catch (Exception ex)
{
MessageBox.Show("" + ex.Message);
}
}
For Video of this process click here:
ALL DONE. THANKS
Comments
Post a Comment