0
我還沒有看到任何與此相關的帖子,但在窗體上繪製的線條應該在圍繞窗體的邊框之前停止5px,但它沒有。此行的目的是在需要時將一個表單上的兩個不同的用戶控件分開。在C#表單繪製的線條太長
protected override void OnPaint(PaintEventArgs e)
{
base.OnPaint(e);
if (optionalSecondPanel != null)
{
Graphics g;
g = e.Graphics;
Pen myPen = new System.Drawing.Pen(System.Drawing.Color.Black);
g.DrawLine(myPen, mainPanel.Width + 5, btnPannel.Bottom + 5, mainPanel.Width + 5, this.Height - 5);
myPen.Dispose();
g.Dispose();
}
}
但是,當在屏幕上繪製時,將用戶控件分隔的線條一直延伸到窗體的底部。它應該不會停止。
因此,如果我將其更改爲'this.Height-50',則該行的底部出現並且可見。爲什麼然後是-5不工作/可見。 –
也許該面板的底部比預期的要低?嘗試更大的值,讓我知道發生了什麼。 – dckuehn
所以,如果我增加我減去的數字,然後我的線顯示。我的表格高度爲612px,因此'this.Height-5'應該會在結束前停止。 –