I need to call tabControl1_SelectedIndexChanged from Form1 in Form2
I have no idea how do 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.
In general, you don’t call events from other classes. The idea is that events expose subscribe/unsubscribe behaviour. The implementation can choose to also expose a method which raises the event, but it doesn’t have to – and if the control you’re using doesn’t expose such a method for the
SelectedIndexChangedevent, you can’t force it to.It’s not clear what you’re trying to achieve, but you may be able to programmatically select the appropriate tab instead – I’d expect that to raise the appropriate event. Rather than expose the tab control directly from
Form1toForm2(which I hope are only placeholder names – give your forms meaningful names 🙂 it would be cleaner to expose a method inForm1to perform the selection of the appropriate tab. That’s a more meaningful operation to perform onForm1– it doesn’t rely as heavily on the implementation details. On the other hand, you may be able to create an even cleaner design using MVP patterns (or whatever suits you best).