简体   繁体   English

C# WinForm 菜单条

[英]C# WinForm Menu Strip

I m use to ASP.NET with masterpage and session.我使用 ASP.NET 和母版页和 session。 i put the menu in masterpage.我把菜单放在母版页中。 After sucsessfuly login i save the variable in session.成功登录后,我将变量保存在 session 中。

Now im working with Winform.现在我正在使用 Winform。 the Session i replace with variable Session 我用变量替换
and the master page i replace with Form和我用表格替换的母版页

so after succsseuly login i save in the variable insted of Session and use the menu strip to switch off and on the panel.所以在成功登录后,我保存在 Session 的变量 insted 中,并使用菜单条关闭和打开面板。

public partial class Principale : Form
    static string _ClientId;
    public static string ClientId
    {
        get { return _ClientId; }
        set { _ClientId = value; }
    }


    LeOrdre_BL oOrdre_BL = new LeOrdre_BL();
    LeOrdreStatut_Entite_BL oOrdreStat_BL = new LeOrdreStatut_Entite_BL();

    public Principale()
    {
        InitializeComponent();      
        ClientId = LoginData.Trim().Substring(0, LoginData.Trim().Length - 1);
        panelControl_Ordre.Hide();
        panelControl_Mag.Hide();
    }

    private void ordreToolStripMenuItem_Click(object sender, EventArgs e)
    {
        panelControl_Ordre.Show();
        panelControl_Mag.Hide();
        GetDataOrdre();            
    }

    private void magasinierToolStripMenuItem_Click(object sender, EventArgs e)
    {
        panelControl_Ordre.Hide();
        panelControl_Mag.Show();            
    }

    public void GetDataOrdre()
    {
        try
        {

            bindingSource_OdreStatus.DataSource = oOrdreStat_BL.Get_All_OrdreStatut();
            STATUT_ORDRE.DataSource = bindingSource_OdreStatus;
            STATUT_ORDRE.DisplayMember = "LIBELLE";
            STATUT_ORDRE.ValueMember = "NO";



            bindingSource_Ordre.DataSource = oOrdre_BL.Get_Ordre_BL();               
            dataGridView_ordre.DataSource = bindingSource_Ordre;
            dataGridView_ordre.DataMember = "OrdreTable";

        }
        catch (Exception excThrown)
        {
            lbl_Princ_Err.Text = excThrown.Message;
        }
    }

Am i in the right way to do this or Do you have another idea to replace ASP.NET Masterpage in Winform?我是否以正确的方式执行此操作,或者您是否有其他想法来替换 Winform 中的 ASP.NET Masterpage?

Thanx in advance提前感谢

Have you tried using an MdiContainer.您是否尝试过使用 MdiContainer。 The user state could be stored as a variable in the form that is the mdi container?用户 state 可以存储为 mdi 容器形式的变量吗?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM