The line and shape controls are designed, just like their VB6 predecessors, to be at the bottom of the z-order.
If you which to draw a line on a picture box you could do this at runtime with code similar to the following example that draws an orange line horizontally across the middle of a picturebox control:
Dim intY As Integer = PictureBox1.Height / 2
PictureBox1.CreateGraphics.DrawLine(Pens.Orange, PictureBox1.ClientRectangle.Left, intY, PictureBox1.ClientRectangle.Right, intY)
Thanks, now how to erase.
I am using a verticle line that moves across the picturebox, but using your example, I would delay a little, and try to erase the line. But inplace of Pens.Orange, I would want to use the Picturebox1.BackColor . How does one convert that to a pens color or something legal in the first parameter of DrawLine?
Barry
To use the same color as the PictureBox.BackColor all you need to do is create a new pen.
For example:
Dim intY As Integer = PictureBox1.Height / 2
Dim p As New System.Drawing.Pen(PictureBox1.BackColor)
PictureBox1.CreateGraphics.DrawLine(p, PictureBox1.ClientRectangle.Left, intY, PictureBox1.ClientRectangle.Right, intY)
To remove the line simply call:
PictureBox1.Refresh