I have a Form and a UserControl. The UserControl has a menu, and the form has a tabstrip (General, Food, Vitamins etc).
In the UserControl, I have the following code: (Form name is frmForm, the tab names in the form are tabGeneral,tabFood, tabVitamins)
frmForm fm=new frmForm();
fm.tabMain.Selected=tabVitamins;
I call these line from the UserControl to capture the tab to get selected on the form, but it does not select the vitamins tab.
Where am I going wrong? I have access specifier as Protected Internal for tabs in the form.
Please advice.
Thanks,
Karthick
When you write
new frmForm(), you’re creating a completely new instance offrmForm, which is then discarded.To get the
frmForminstance that holds your control, call theFindForm()method and cast tofrmForm.For example:
If the control is on some other form, this code won’t do anything.
By the way, Hungarian notation is frowned upon in .Net.
Your form should probably be named something like
MainForm.