What is wrong w/my code?
this.comboBox1.SelectedIndex = _f3.dataGridView2.SelectedRows[0].Index;
my datagrid is in form3 and my combobox is in form 2. HOW could I implement something like this?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Instead, you declare one public integer in form2 and when you want to get the selected row index of the datagridview you can use the CurrentRowIndex property to get the index of the datagridview selected row like, in form3 you get the selectedindex global varaible from form2 and assign the CurrentRowIndex, or declare a public method which should return the selected row index when ever required
In form2 you write something like
In form3 you write the method like
EDIT:
You can use instead
In form3 under the SelectionChanged event of datagridview you do the following thing
and also declare the selectedindex as an integer as a public variable like
and in form2 directly get the selectedindex by using the global variable like below,
get the selectedindex when ever required.