c# - 单击中间时关闭任何 TabControl TabPage

标签 c# winforms tabcontrol mouseclick-event

我希望能够在 TabPage 上中键单击选项卡并将其从 TabControl 中删除,但即使启用了 HotTracking,我也不知道该怎么做捕获我中间单击的选项卡。

有办法吗?

最佳答案

您可以在 TabControlMouseClick 事件上执行类似的操作:

private void tabControl_MouseClick(object sender, MouseEventArgs e)
{
    if (e.Button == System.Windows.Forms.MouseButtons.Middle)
    {
        for (int i = 0; i < tabControl.TabCount; i++)
        {
            if (tabControl.GetTabRect(i).Contains(e.Location))
            {
                tabPaControl.TabPages[i].Dispose();
            }
        }
    }
}

关于c# - 单击中间时关闭任何 TabControl TabPage,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33422859/

相关文章:

c# - 更改 Windows 窗体上的边框颜色

c# - 我应该使用什么控件来显示动态数据(图片、名称等),例如 ASP.NET 上的 html 表?

winforms - 在 RichTextBox 中显示表格输出

c# - 如何将 Timespan 对象格式化为字符串

c# - 在移动鼠标并按住右键的同时画一条线

c# - 将整数添加到名称中

c# - 对齐 wpf tabcontrol strip

c# - 无法向 Unity 和 Entity Framework 注册 DbConnection

c# - 将 Nullable<DateTime> 序列化为 XML