Click here to Skip to main content
15,940,550 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
See more:
Hi guys.

I have a problem on how to display the selected row from the datagridview to a form that contains textboxes by using the context menu strip.
I have not yet tried anything since this is the first time that I encountered this. I have already added a context menu strip to my form where datagridview is. What I am looking for now is on how to display the selected row to another form for me to be able to edit it. Thanks in advance,. :)
V. 23-Jan-15 2:40am    
and what has the menustrip to do with it? That's somewhat unclear to me. Does the information in the datagrid need to be passed to the textboxes in the other form? (do not reply to this comment, rather update your question)

1 solution

EditStudentInformation frm = new EditStudentInformation();
            frm.label2.Text = this.dg_studSearch.CurrentRow.Cells[0].Value.ToString();
            frm.textBox2.Text = this.dg_studSearch.CurrentRow.Cells[1].Value.ToString();
            frm.textBox3.Text = this.dg_studSearch.CurrentRow.Cells[2].Value.ToString();
            frm.textBox1.Text = this.dg_studSearch.CurrentRow.Cells[3].Value.ToString();
            frm.textBox5.Text = this.dg_studSearch.CurrentRow.Cells[7].Value.ToString();
            frm.textBox6.Text = this.dg_studSearch.CurrentRow.Cells[8].Value.ToString();
            frm.textBox7.Text = this.dg_studSearch.CurrentRow.Cells[9].Value.ToString();
            frm.label8.Text = this.dg_studSearch.CurrentRow.Cells[4].Value.ToString();
            frm.label13.Text = this.dg_studSearch.CurrentRow.Cells[10].Value.ToString();
            frm.textBox8.Text = this.dg_studSearch.CurrentRow.Cells[11].Value.ToString();
            frm.textBox4.Text = this.dg_studSearch.CurrentRow.Cells[12].Value.ToString();

Share this answer

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900