private void dataGridView1_CellClick(object sender, DataGridViewCellEventArgs e) { string fname, sname, oname; if (e.RowIndex >= 0) { DataGridViewRow row = this.dataGridView1.Rows[e.RowIndex]; //using id to pull picture label1.Text = row.Cells[0].Value.ToString(); selectClass.selectImageFromEmployee(label1.Text, pictureBox1); fname = row.Cells[1].Value.ToString(); sname = row.Cells[2].Value.ToString(); oname = row.Cells[3].Value.ToString(); txtEmpname.Text = fname + " " + sname + " " + oname; txtEmpPhone.Text = row.Cells[6].Value.ToString(); txtemail.Text = row.Cells[7].Value.ToString(); txtdepartment.Text = row.Cells[10].Value.ToString(); txtqualification.Text = row.Cells[12].Value.ToString(); txtresidence.Text = row.Cells[13].Value.ToString(); txtreference.Text = row.Cells[14].Value.ToString(); txtrefcontact.Text = row.Cells[15].Value.ToString(); } }