我试图在tabcontrol的tabpage面板上添加关闭按钮或'X',我已经通过阅读此stackoverflow问题成功完成了此操作.
问题是标签页标题和X标志合并在一起.我发现tabpage title面板没有根据标题文本调整大小.
这是代码:
//This code will render a "x" mark at the end of the Tab caption.
e.Graphics.DrawString("X", e.Font, Brushes.Black, e.Bounds.Right + 15, e.Bounds.Top + 4);
e.Graphics.DrawString(this.tabControl1.TabPages[e.Index].Text, e.Font, Brushes.Black, e.Bounds.Left+5, e.Bounds.Top + 4);
e.DrawFocusRectangle();
Run Code Online (Sandbox Code Playgroud)
结果是在这里我改变了e.bounds.right价值,但它仍然没有用.