Change accept button with tabs

前端 未结 3 1363
伪装坚强ぢ
伪装坚强ぢ 2021-01-06 12:59

I have a windows form application written in C# and it has three tabs and I would like the accept button change with the active tab. Like When I am in tab 1 I want button _

3条回答
  •  一生所求
    2021-01-06 13:47

    TabControl have SelectedIndexChanged event.

    private void tabControl1_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (tabControl1.SelectedTab == tabControl1.TabPages["RenewalTab"])
            {
                this.AcceptButton = btnRenewal;
            }
            else if (tabControl1.SelectedTab == tabControl1.TabPages["SellerTab"])
            {
                this.AcceptButton = btnSeller;
            }
        }
    

提交回复
热议问题