C# 如何从选项卡控件中删除点焦点矩形?

C# 如何从选项卡控件中删除点焦点矩形?,c#,.net,winforms,focus,tabcontrol,C#,.net,Winforms,Focus,Tabcontrol,我正在尝试从自定义选项卡控件中删除点焦点矩形。我什么都试过了,但我没能去掉那个长方形 如图所示,在我的应用程序设计中,焦点矩形令人不安 请帮忙 要删除焦点提示,必须将UserPaint设置为true,然后自己绘制整个选项卡控件,包括边框、文本、背景、高亮显示、热跟踪等 以下代码仅绘制选项卡文本和背景: public class TC2 : TabControl { public TC2() { this.SetStyle(ControlStyles.AllPaintin

我正在尝试从自定义
选项卡控件中删除点焦点矩形。我什么都试过了,但我没能去掉那个长方形

如图所示,在我的应用程序设计中,焦点矩形令人不安


请帮忙

要删除焦点提示,必须将
UserPaint
设置为true,然后自己绘制整个选项卡控件,包括边框、文本、背景、高亮显示、热跟踪等

以下代码仅绘制选项卡文本和背景:

public class TC2 : TabControl {
    public TC2() {
        this.SetStyle(ControlStyles.AllPaintingInWmPaint | ControlStyles.OptimizedDoubleBuffer | ControlStyles.ResizeRedraw | ControlStyles.UserPaint, true);
    }

    protected override void OnPaint(PaintEventArgs e) {
        base.OnPaint(e);
        var g = e.Graphics;

        TabPage currentTab = this.SelectedTab;
        for (int i = 0; i < TabPages.Count; i++) {
            TabPage tp = TabPages[i];
            Rectangle r = GetTabRect(i);
            Brush b = (tp == currentTab ? Brushes.LightSteelBlue : Brushes.LightGray);
            g.FillRectangle(b, r);
            TextRenderer.DrawText(g, tp.Text, tp.Font, r, tp.ForeColor);
        }
    }

    protected override void OnPaintBackground(PaintEventArgs e) {
        base.OnPaintBackground(e);
    }
}
公共类TC2:TabControl{
公共TC2(){
此.SetStyle(ControlStyles.AllPaintingInWmPaint | ControlStyles.OptimizedDoubleBuffer | ControlStyles.ResizerDraw | ControlStyles.UserPaint,true);
}
受保护的覆盖无效OnPaint(PaintEventArgs e){
基础漆(e);
var g=e.图形;
TabPage currentTab=this.SelectedTab;
对于(int i=0;i
您尝试过这个吗?是的,它对我不起作用。焦点矩形在运行时显示,而不仅仅是在设计时?向我们展示绘图代码!向我们展示绘图代码!我的自定义选项卡控件已执行此操作。即使使用自定义绘制,焦点矩形仍会显示。我不知道该怎么办:(
DrawMode=TabDrawMode.OwnerDrawFixed
不等于
SetStyle(UserPaint)
。此时,您必须提供一些代码,否则就是猜测。@Loathing+1。我需要这个。