C# WinForm Menu Strip

本文关键字:Strip Menu WinForm | 更新日期: 2023-09-27 18:05:19

我习惯使用ASP。. NET的主页和会话。我把菜单放到主页里了。成功登录后,我将变量保存在会话中。

现在我正在使用Winform。我将会话替换为变量
用Form

代替母版页

所以在成功登录后,我保存在变量中而不是Session,并使用菜单条来关闭和打开面板。

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;
        }
    }

我在正确的方式做到这一点或你有另一个想法来取代ASP。. NET主页在Winform ?

提前致谢

C# WinForm Menu Strip

您尝试过使用mdiccontainer吗?用户状态可以以mdi容器的形式作为变量存储。