0

In Windows form, I am trying to render the Line by setting style as DashStyle.Dot by using Graphics and Graphics page scale as 0.50. But the line does not rendered in form. Please anyone suggest me on this....

refer to the below code snippet:

 protected override void OnPaint(PaintEventArgs e)
    {
        gp = e.Graphics;
        gp.PageScale = 0.50f;
        using (System.Drawing.SolidBrush myBrush = new System.Drawing.SolidBrush(System.Drawing.Color.White))
        {
            gp.FillRectangle(myBrush, new RectangleF(30, 100, 400, 600));
        }            
        // Create pen.
        using (Pen blackPen = new Pen(Color.Black, 0))
        {
            blackPen.DashStyle = System.Drawing.Drawing2D.DashStyle.Dot;
            gp.DrawLine(blackPen, 30, 200, 430, 200);
        }
    }

1 Answers1

0

I believe it's being drawn but it has too small width so it's practically invisible. Try another width, similar to:

        using (Pen blackPen = new Pen(Color.Black, 4.0F))
        {
            blackPen.DashStyle = System.Drawing.Drawing2D.DashStyle.Dot;
            gp.DrawLine(blackPen, 30, 200, 430, 200);
        }
S.Dav
  • 2,436
  • 16
  • 22
  • Hi Dev, thanks for your reply. Actually this error will raise only when we set the Graphics pagescale as 0.5. Otherwise, it will work. – Naga Nathan Feb 02 '17 at 04:53
  • I didn't get any error. Here, i have mentioning an error as the DashStyle.Dot Line is not render while we set the pagescale as 0.5. But if I try to set the value is less or greater than of 0.5, it will work fine. In my project, I have created the Pen and set width as Zero by default. – Naga Nathan Feb 02 '17 at 09:58