Command to open a form in a specific tabcontrol.
Example: in a form I have a tabcontrol with two tabs: register and consult. Then I wanted (with a button) to open this form directly in the consult tab.
Command to open a form in a specific tabcontrol.
Example: in a form I have a tabcontrol with two tabs: register and consult. Then I wanted (with a button) to open this form directly in the consult tab.
Create some form in which the form to be opened knows which tab it needs to select and then select it using TabControl.SelectedTab
.
You can, for example, pass enum
by parameter in the form constructor.
See:
public class Form1 : Form
{
public Form1(TipoTab tipoTab)
{
if(tipoTab == TipoTab.Cadastro)
{
tabControl1.SelectedTab = tabCadastro;
}
else
{
tanControl1.SelectedTab = tabConsulta;
}
}
}
public enum TipoTab
{
Cadastro,
Consulta
}
And use would be something like
public static void botaoCadastro_click(object sender, EventArgs e)
{
var form = new Form(TipoTab.Cadastro);
form.ShowDialog();
}
public static void botaoConsulta_click(object sender, EventArgs e)
{
var form = new Form(TipoTab.Consulta);
form.ShowDialog();
}