問題描述
我有一個用 C# 編寫的 Windows 窗體應用程序,它有三個選項卡,我想用活動選項卡更改接受按鈕.就像當我在標簽 1 中時,我希望按鈕 _1 成為接受按鈕,但是當我在標簽 3 中時,我希望 button_3 成為我的接受按鈕.我無法弄清楚如何做到這一點,也許我在搜索中沒有使用正確的術語,但我在網(wǎng)上找不到任何好的資源來告訴我如何做到這一點.
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 _1 to be the accept button but when I am in tab 3 I want button_3 to be my accept button. I cannot figure out how to do this and maybe I'm not using the correct terms in my searches but I cannot find any good resources online showing me how to do this.
推薦答案
最好的猜測是連接到 SelectedIndexChanged
選項卡控件上的事件并更改 AcceptButton
取決于選擇的選項卡.偽代碼:
Best guess would be to hook in to the SelectedIndexChanged
event on the tab control and change the AcceptButton
depending on which tab is selected. Pseudo-code:
Form_OnLoad(...)
{
this.tabControl.SelectedIndexChanged += (s,e) => {
TabControl tab = s as TabControl;
switch (tab.SelectedIndex){
case 3:
this.AcceptButton = this.button_3;
break;
case 2:
this.AcceptButton = this.button_2;
break;
case 1:
default:
this.AcceptButton = this.button_1;
break;
}
};
}
或者類似的東西.
這篇關于更改帶有選項卡的接受按鈕的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網(wǎng)!