private void dataGridView1_CellClick(object sender, DataGridViewCellEventArgs e) { if (e.ColumnIndex == 0) { MessageBox.Show("cell clicked"); int i = e.RowIndex; DataGridViewRow row = dataGridView1.Rows[i]; // string id = row.Cells[0].Value.ToString(); string reg = row.Cells[2].Value.ToString(); List <string> l = new List <string>(); // l.Add(id); l.Add(reg); if (flag == 1) { Groupstudent frm = new Groupstudent(Convert.ToInt32(row.Cells[1].Value), l); frm.Show(); } else if (flag == 2) { updategrp f = new updategrp(Convert.ToInt32(row.Cells[1].Value), l); f.Show(); } } }
private void dataGridView1_CellClick_1(object sender, DataGridViewCellEventArgs e) { if (e.ColumnIndex == 4) { int index = e.RowIndex;// get the Row Index DataGridViewRow selectedRow = dataGridView1.Rows[index]; SqlConnection c = new SqlConnection(constr); int i = e.RowIndex; DataGridViewRow row = dataGridView1.Rows[i]; string grpid = row.Cells[0].Value.ToString(); string stdid = row.Cells[1].Value.ToString(); string ststus = row.Cells[2].Value.ToString(); string assdate = row.Cells[3].Value.ToString(); List <string> l = new List <string>(); l.Add(grpid); l.Add(stdid); l.Add(ststus); l.Add(assdate); updategrp frm = new updategrp(Convert.ToInt32(row.Cells[0].Value), l); frm.Show(); } }