简体   繁体   English

从 WinForms UserControl 中删除边框

[英]Removing Border from WinForms UserControl

I have UserControl with black border inside.我有带有黑色边框的 UserControl。 I want to remove the border or change its color.我想删除边框或更改其颜色。

形式形象 . .

Found solution but it does not remove the border:找到解决方案,但它没有删除边框:

public FolderView() {
    InitializeComponent();
    base.BorderStyle = BorderStyle.None;
    this.BorderStyle = BorderStyle.None;
}

private BorderStyle border;

public new BorderStyle BorderStyle {
    get { return border; }
    set {
        border = value;
        Invalidate();
    }
}

Control is taken from this project .控制来自这个项目

UPDATE: I am trying to draw new border.更新:我正在尝试绘制新边框。 Added these lines of code at the end of OnPaint method in TreeListView class:TreeListView class 的OnPaint方法末尾添加了这些代码行:

Rectangle rect = base.ClientRectangle;
ControlPaint.DrawBorder(e.Graphics, rect, Color.DarkBlue, ButtonBorderStyle.Solid);

However Vertical Scrollbar is painted over my border.然而,垂直滚动条画在我的边框上。 How to resolve this?如何解决这个问题? Also tried same code in FolderViewTree class, but scrollbar pushes border to the left (I want to have scrollbar within the border as it was originally).还在FolderViewTree中尝试了相同的代码,但滚动条将边框推向左侧(我希望在边框内有滚动条,因为它原来是这样)。

在此处输入图像描述

As mentioned in the comments, the border belongs to the TreeView .正如评论中提到的,边框属于TreeView Attached is the screenshot of the designer where you should change the border to None .附件是设计器的屏幕截图,您应该将边框更改为None (Currently, it's set to FixedSingle ). (目前,它设置为FixedSingle )。

在此处输入图像描述

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM