繁体   English   中英

在C#表单上绘制的线太长

[英]Line Drawn On C# Form Too Long

我还没有看到与此相关的任何帖子,但是在表单上绘制的线条应该在表单寄宿生之前停靠5px,但事实并非如此。 该行的目的是根据需要在一个表单上分离两个不同的用户控件。

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

但是,当在屏幕上绘制时,用户控件之间的分隔线会一直到达表单底部。 它不应该停止在应该的时候。

g.DrawLine(myPen, mainPanel.Width + 5, btnPannel.Bottom - 5, mainPanel.Width + 5, this.Height - 5);

我相信.Bottom增加会下降,因此,如果减去5,它应该会增加该条的底部。

暂无
暂无

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

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