winform TabControl 添加关闭按钮 Add close button to TabControl TabPages - C#

来源:互联网 发布:网络彩票概念龙头股 编辑:程序博客网 时间:2024/06/05 03:00
<h1 class="articleTitle" style="font-family: 'Open Sans', Tahoma, Arial, Helvetica, sans-serif; margin: 0px 0px 10px; font-size: 22px; text-shadow: rgb(204, 204, 204) 2px 2px 3px; color: rgb(0, 0, 0); padding: 5px 10px; font-weight: normal; text-align: left; width: 590px; font-style: normal; font-variant: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: rgb(255, 255, 255);">How to Add a Close Button to Tabs in TabControl?</h1>// Create a command button// Set the ImageIndex property to show the second image from the list// Set the Key property to TAB_CLOSE, so we can identify what kind of a button was clickedLidorSystems.IntegralUI.Controls.CommandButton closeButton = new LidorSystems.IntegralUI.Controls.CommandButton();closeButton.ImageIndex = 1;closeButton.Key = "TAB_CLOSE"; // In this demo we are using only one command button// If the button collection is empty, add the close button to itif (this.tabControl1.TabButtons.Count == 0)this.tabControl1.TabButtons.Add(closeButton);

// Check whether there is some tab on top (selected)if (this.tabControl1.SelectedPage != null){// Create a command button// Set the ImageIndex property to show the first image from the list// Set the Key property to TAB_CLOSE, so we can identify what kind of a button was clickedLidorSystems.IntegralUI.Controls.CommandButton closeButton = new LidorSystems.IntegralUI.Controls.CommandButton();closeButton.ImageIndex = 0;closeButton.Key = "TAB_CLOSE"; // In this demo we are using only one command button// If the button collection is empty, add the close button to itif (this.tabControl1.SelectedPage.Buttons.Count == 0)this.tabControl1.SelectedPage.Buttons.Add(closeButton);this.tabControl1.SelectedPage.UseParentButtons = false; // Update the control layout to apply changesthis.tabControl1.UpdateLayout();}

更多信息:
http://www.lidorsystems.com/support/articles/winforms/tabcontrol/tab-close-button.aspx

0 0
原创粉丝点击