且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

根据选项卡控件更改触发事件

更新时间:2023-02-03 23:20:20

我已经很长时间没有使用TabControl了.但是,IIRC,每个TabPage都有一个您可以订阅的VisibleChanged事件. TabControl本身具有可以订阅和使用的Deselected和Selected事件.

无论哪种情况,您都可以获取TabPagem或它的索引,以用于跟踪隐藏的页面和显示的页面.只需跟踪哪个计时器在哪个页面上,并使用给出的信息适当地打开/关闭它们即可.
I haven''t used the TabControl in quite a long time. But, IIRC, every TabPage has a VisibleChanged event you could subscribe to. The TabControl itself has a Deselected and Selected events that you could subscribe to and use.

In either case, you''re getting the TabPagem, or the index of, that you can use to track which page is being hidden and which is being shown. It just a matter of tracking which Timers are on which pages and using the information given to turn them on/off as appropriate.