Customizing a TabControl for the Closing of Individual Tabs

前端 未结 7 1281
囚心锁ツ
囚心锁ツ 2020-12-06 10:33

My scenario is the following:

I am working on a winforms application in C# that has a button inside the main page of a tabcontrol that will generate another tabpag

相关标签:
7条回答
  • 2020-12-06 11:02

    I created a setup that is similar.

    Each control that is added to the tab page at runtime is derived from a special base control I created. This base control has a close button (along with some other features such as safe to close flag).

    Close tab code I'm using on my base control:

     TabPage tabpage = (TabPage)this.Parent;
    TabControl tabControl = (TabControl)tabpage.Parent;
    
    tabControl.TabPages.Remove(parent);
    
    0 讨论(0)
提交回复
热议问题