0

I am trying to make two reference line which shows the exact center position of the picture box in Visual Basic.net 2019. could you please help with it. I am attaching sample image How it seems like.

While saving the image these lines shouldn't include in the final image.

Is it possible?! If yes Please help me with it. Thanks in Advance.

enter image description here

Abdelsalam Shahlol
  • 1,621
  • 1
  • 20
  • 31

1 Answers1

0
Public Class Form1
Private Sub PictureBox1_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles PictureBox1.Paint

    Dim g As Graphics = e.Graphics
    Dim pn As New Pen(Color.Black) '~~~ color of the lines

    Dim x As Integer
    Dim y As Integer

    Dim intSpacing1 As Integer = 320  '~~~ spacing between adjacent lines
    Dim intSpacing2 As Integer = 240

    '~~~ Draw the horizontal lines
    x = PictureBox1.Width
    For y = 0 To PictureBox1.Height Step intSpacing2
        g.DrawLine(pn, New Point(0, y), New Point(x, y))
    Next

    '~~~ Draw the vertical lines
    y = PictureBox1.Height
    For x = 0 To PictureBox1.Height Step intSpacing1
        g.DrawLine(pn, New Point(x, 0), New Point(x, y))
    Next

End Sub

End Class

  • Hello @Ramesh, could you provide more description to your answer? Please check Stack Overflow guide on how to answer https://stackoverflow.com/help/how-to-answer – Abdelsalam Shahlol May 19 '20 at 16:49