实现功能:program中传入参数为"factory"时,显示tabpage,传入参数为""时,隐藏tabpage。
program.cs
static class Program
{
/// <summary>
/// 应用程序的主入口点。
/// </summary>
[STAThread]
static void Main(string[] args)
{
string code = "";
//string code = "factory";
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new FrmMain(code));
}
}
主函数中:
SettingUserControl _SettingUserControl = new SettingUserControl();
public FrmMain(string args)
{
InitializeComponent();
//设置是否隐藏
isHide(args);
}
private void isHide(string args)
{
if(args != "factory")
{
foreach (Control control in _SettingUserControl.Controls)
{
if (control is TabControl)
{
TabControl tc = (TabControl)control;
//隐藏TabPages[2],TabPages[3]
tc.Controls["tabpage3"].Parent = null;
tc.Controls["tabpage4"].Parent = null;
}
}
}
}