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

<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

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

霍先生的虚拟宇宙网络

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值