private int ValidateData()
{
    int flag = 1;
    if (txtEmpNo.TextLength < 8)
    {
        MessageBox.Show("Employee Number must be 8 Digits Long","Message");
        flag = 0;
    }
     return flag;
}
private void btnProfile_Click(object sender, EventArgs e)
{
    try
    {
        Profile pf = new Profile("");
        if (ValidateData() == 1)
        {
            if (pf!=null)
            {
                pf = new Profile("");
                pf.Focus(); 
            }
            else
            {
               pf = new Profile(txtEmpNo.Text);
               pf.Show();
            }
            Qualification  qa = new Qualification("");
            qa.Close();
            Experience  ex = new Experience("");
            ex.Close();
            History hs = new History("");
            hs.Close();
        }
    }
    catch (Exception ex)
    {
        if (ex is IndexOutOfRangeException)
        {
            MessageBox.Show("Employee Not Found");
        }
        else if (ex is OleDbException)
        {
            MessageBox.Show("Please Enter Employee Valid No.");
        }
        else
        {
            MessageBox.Show(ex.ToString());
        }
    }
}
我创建了一个主表单,其中包括 4 个按钮,单击这些按钮时会打开另外 4 个表单...我想实现一些功能,如果我单击一个按钮,它将打开相应的表单,如果其他表单打开,则其他表单自动关闭...第二件事是如果表单已经打开然后不再打开它只需将其聚焦...
我已经为此做了一些编码,但我无法获得所需的输出。