2015-09-29 121 views

回答

0

你必須將所有內容移動SplitContainer內。該容器包含兩個面板和一個分隔器。您必須將控件放置在另一面上,並將圖像放在另一面板上。

在你的特殊情況下,你可能不得不重新開始。

使用設計師,您應該設置SplitContainer的Dock財產填充。您可以通過選擇並拖動來移動分隔線(只有在選擇了SplitContainer的情況下才可以)。一旦分配器位於正確的位置,將FixedPanel屬性設置爲左側面板可能是明智的做法,因爲您可能不希望此面板在最大化時增大。
只要將屬性IsSplitterFixed設置爲False,仍然可以在應用程序中移動分隔線。

0
public class VertSep : Control 
{ 
    private Color lineColor; 
    private Pen linePen; 

    public VertSep() 
    { 
     this.LineColor = Color.LightGray; 
     SetStyle(ControlStyles.SupportsTransparentBackColor, true); 
    } 

    public Color LineColor 
    { 
     get 
     { 
      return this.lineColor; 
     } 
     set 
     { 
      this.lineColor = value; 

      this.linePen = new Pen(this.lineColor, 1); 
      this.linePen.Alignment = PenAlignment.Inset; 

      Refresh(); 
     } 
    } 

    protected override void Dispose(bool disposing) 
    { 
     if(disposing && this.linePen != null) 
     { 
      this.linePen.Dispose(); 
      this.linePen = null; 
     } 

     base.Dispose(disposing); 
    } 

    protected override void OnPaint(PaintEventArgs e) 
    { 
     var g = e.Graphics; 
     int x = this.Width/2; 

     g.DrawLine(linePen, x, 0, x, this.Height); 

     base.OnPaint(e); 
    } 
} 
相關問題