C#,BindingNavigator,Ugly行在右端 [英] C#, BindingNavigator, Ugly line at the right end

查看:57
本文介绍了C#,BindingNavigator,Ugly行在右端的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何摆脱这条丑陋的线?

How do I get rid of this ugly line?

在一个空的窗体上绘制默认的绑定导航器,您将看到问题。 RenderMode是ManagerRenderMode。我想要这种渲染模式,以便将鼠标悬停在颜色上是正确的。但是,如果我将系统切换为渲染模式,则难看的线条消失了,但是鼠标悬停在颜色/效果上变得难看。

Draw a default bindingnavigator on an empty Form and you will see the problem. RenderMode is ManagerRenderMode. I want this render mode so the mouse over colors is correct. However, If I switch to System as rendermode the ugly line disapears, but then mouse over color/effect gets ugly.

现在,但是什么也没有。

I have been looking around for a solution for some time now, but nothing. Maybe someone here have seen this problem before?

推荐答案

这不是 BindingNavigator 特定问题,但 BindingNavigator 继承的 ToolStrip

It's not a BindingNavigator specific issue, but the ToolStrip which BindingNavigator inherits.

这是由 DrawToolStripBorder 方法时, ToolStripProfessionalRenderer RoundedEdges 属性为 true (默认值)。

It's caused by the DrawToolStripBorder method when the ToolStripProfessionalRenderer class RoundedEdges property is true (the default).

为了将其关闭,我可以建议以下帮助方法:

In order to turn it off, I can suggest the following helper method:

public static class WindowsFormsExtensions
{
    public static void DisableRoundedEdges(this ToolStripRenderer renderer)
    {
        var professionalRenderer = renderer as ToolStripProfessionalRenderer;
        if (professionalRenderer != null)
            professionalRenderer.RoundedEdges = false;
    }
}

现在您可以为特定控件将其关闭(它在设计时不可用,因此必须在运行时在窗体/控件构造函数或load事件中):

Now you can turn it off for the specific control (it's not available at design time, so it has to be at run time inside your form/control constructor or load event):

this.bindingNavigator1.Renderer.DisableRoundedEdges();

或要全局禁用它,请在 Main 方法,然后调用 Application.Run

or to disable it globally, add the following in your Main method before calling Application.Run:

ToolStripManager.Renderer.DisableRoundedEdges();

这篇关于C#,BindingNavigator,Ugly行在右端的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆