您的位置:首页 > 编程语言 > C#

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

2016-09-22 17:39 701 查看
<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 clicked
LidorSystems.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 it
if (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 clicked
LidorSystems.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 it
if (this.tabControl1.SelectedPage.Buttons.Count == 0)
this.tabControl1.SelectedPage.Buttons.Add(closeButton);
this.tabControl1.SelectedPage.UseParentButtons = false;

// Update the control layout to apply changes
this.tabControl1.UpdateLayout();
}


更多信息:
http://www.lidorsystems.com/support/articles/winforms/tabcontrol/tab-close-button.aspx
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: