简体   繁体   中英

Removing Border from WinForms UserControl

I have UserControl with black border inside. 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:

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).

在此处输入图像描述

As mentioned in the comments, the border belongs to the TreeView . Attached is the screenshot of the designer where you should change the border to None . (Currently, it's set to FixedSingle ).

在此处输入图像描述

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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