CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 5 of 5

Thread: Picturebox

  1. #1
    Join Date
    Feb 2016
    Posts
    29

    Cool Picturebox

    Hello all,

    So im trying to figure out how to draw a line on a form that will lay over top a picture box. Im using an image
    in a picture box and want to draw a line which will go over the top. Right now I can draw a line that goes the
    form but is drawn behind the picture box. Any way to bring it to the front? This is the code for my line.

    Code:
    protected override void OnPaint(PaintEventArgs e)//draw line
            {
    
    
    
                Pen pen = new Pen(Color.FromArgb(255, 0, 0, 0));
                e.Graphics.DrawLine(pen, 100, 100, 300, 500);
    
    
            }
    and help is greatly appreciated.

    thanks

  2. #2
    Join Date
    Jun 2011
    Location
    Buenos Aires, Argentina
    Posts
    130

    Re: Picturebox

    You could use a second pictureBox/label/etc with a .BackgroundColor, and then just set .Location and .Size according to needs, and even change .Visible or .SendToBack() or .BringToFront().

  3. #3
    Join Date
    Feb 2016
    Posts
    29

    Re: Picturebox

    Thanks much

  4. #4
    Join Date
    Feb 2016
    Posts
    29

    Re: Picturebox

    Same thread but similar question...hope its ok.

    So I created a plane which is 250 x 250. Im trying to draw a line at an angle. So lets say for example I want to draw a 45 degree angle from center which is 125, 125 on the plane. I know using x1 = x + cos(angle)*length and
    y1 = y + Sin(angle) * length gives you the end points but if the length is too long it scales off the plane which makes the line look wrong. Is there a way to do it without using length ? I basically want to just input degrees and have a line show on a plane that is at that angle from center.
    thanks much for any help.

  5. #5
    Join Date
    May 2002
    Posts
    1,798

    Re: Picturebox

    Check out:

    Drawing on picture box images D*****hka Madushan lk, 24 Jan 2012
    http://www.codeproject.com/Tips/3189...ure-box-images
    mpliam

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured