I created one xtratab control.I created two tab pages in that named entry and reports. I created one more windows form and in that I created menu. in that menu I created two option bars name entry and report. when I click on entry in menu than that xtra tab page should come with entry tab selected. If I click on report in menu than that xtratab report page should open.
I searched in net but they told how to specify tab page in form while form is loading like Tab.SelectedTabPage = xtraTabPage2;
But this is not suitable for my condition.
The easiest way to achive your goal is to set your XtraTabControl
's and it's tab member modifier to public. Then at your Another Form
's constructor, pass your First Form
as a parameter.
Your AnotherForm
should look like this:
private readonly Form1 _form1;
public AnotherForm(Form1 form1)
{
_form1 = form1;
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
_form1.xtraTabControl1.SelectedTabPage = _form1.xtraTabPage1;
}
private void button2_Click(object sender, EventArgs e)
{
_form1.xtraTabControl1.SelectedTabPage = _form1.xtraTabPage2;
}
Now call AnotherForm
from your main form: new AnotherForm(this).ShowDialog();
If you don't want to set xtraTabPage
's modifier to public you can simply use SelectedTabPageIndex
which is integer type.