Hi,
I am binding student details in the first form datagridview.when i doubleclick the datagridview cell.i collect all the content releated to that cell.and pass that value to second form constructor ther i am get all the values and display it in the message box.in your case you bind it your own design.
private void dataGridView1_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
{
if (e.ColumnIndex >= 0 && e.RowIndex >= 0)
{
StudentInfo info = new StudentInfo();
info.StdNo =Convert.ToInt32
(dataGridView1.Rows[dataGridView1.CurrentRow.Index].Cells[0].Value.ToString());
info.Name =
dataGridView1.Rows[dataGridView1.CurrentRow.Index].Cells[1].Value.ToString();
info.Lecture =
dataGridView1.Rows[dataGridView1.CurrentRow.Index].Cells[2].Value.ToString();
info.Year = Convert.ToInt32
(dataGridView1.Rows[dataGridView1.CurrentRow.Index].Cells[3].Value.ToString());
info.Exam1 = Convert.ToInt32
(dataGridView1.Rows[dataGridView1.CurrentRow.Index].Cells[4].Value.ToString());
Form2 frm = new Form2(info);
frm.Show();
}
}
}
public class StudentInfo
{
private int stdNo;
public int StdNo
{
get { return stdNo; }
set { stdNo = value; }
}
private string name;
public string Name
{
get { return name; }
set { name = value; }
}
private string surName;
public string SurName
{
get { return surName; }
set { surName = value; }
}
private string lecture;
public string Lecture
{
get { return lecture; }
set { lecture = value; }
}
private int year;
public int Year
{
get { return year; }
set { year = value; }
}
private int exam1;
public int Exam1
{
get { return exam1; }
set { exam1 = value; }
}
}
StudentInfo stuInfo;
public Form2(StudentInfo info)
{
InitializeComponent();
stuInfo=new StudentInfo();
stuInfo=info;
}
private void Form2_Load(object sender, EventArgs e)
{
MessageBox.Show(stuInfo.StdNo.ToString() + stuInfo.Name + stuInfo.Lecture + stuInfo.Year + stuInfo.Exam1);
}
Best Regards,
C.Gnanadurai
-----------------------
Please mark the post as answer if it is helpfull to you