簡體   English   中英

從 WinForms UserControl 中刪除邊框

[英]Removing Border from WinForms UserControl

我有帶有黑色邊框的 UserControl。 我想刪除邊框或更改其顏色。

形式形象 .

找到解決方案,但它沒有刪除邊框:

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();
    }
}

控制來自這個項目

更新:我正在嘗試繪制新邊框。 TreeListView class 的OnPaint方法末尾添加了這些代碼行:

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

然而,垂直滾動條畫在我的邊框上。 如何解決這個問題? 還在FolderViewTree中嘗試了相同的代碼,但滾動條將邊框推向左側(我希望在邊框內有滾動條,因為它原來是這樣)。

在此處輸入圖像描述

正如評論中提到的,邊框屬於TreeView 附件是設計器的屏幕截圖,您應該將邊框更改為None (目前,它設置為FixedSingle )。

在此處輸入圖像描述

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM