CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Jun 2010
    Posts
    2

    Refresh issue with line drawing on panel.

    Hello All,

    I am working on an appplication where i have a form window with one panel control and two buttons controls. The workflow of my application is as follows:

    1. Select an image from first buuton.

    2. Display the image on the panel control on first button click.

    3. Draw line onto the image set with the panel on second button click.

    Also i have set the AutoScrollMinSize property to set the scrollbars according to the size of image and length of lines drawn.

    I have implemented the paint event for my panel and use the draw method of PaintEventArgs class ( For Ex: e.Graphics.Drawimage(...,.., ...) and

    e.Graphics.DrawLine(...,.., ...) where e is an object of PaintEventArgs class )

    Now, my problem is that on using the scrollbars, my drawn lines are broken down. Can somebody help me on this problem. Please help.

  2. #2
    Join Date
    Jun 2008
    Posts
    2,477

    Re: Refresh issue with line drawing on panel.

    You should use a PictureBox to display a picture, that is what they are there for. You can then draw directly onto the image and you will not be limited by the visible client area.
    If you liked my post go ahead and give me an upvote so that my epee.... ahem, reputation will grow.

    Yes; I have a blog too - http://the-angry-gorilla.com/

  3. #3
    Join Date
    Jun 2010
    Posts
    2

    Re: Refresh issue with line drawing on panel.

    Thanks for the reply BED781.

    I can not change the control but i have fixed the problem by using other overloaded method for drawline.
    e.Graphics.DrawLine( Color, x1, y1, x2, y2 )

    Pass the line coordinates for draw as :
    x1 = x1 + panel1.AutoscrollPosition.X
    y1 = y1 + panel1.Autoscrollposition.Y
    x2 = x1+ x2+ + panel1.AutoscrollPosition.X
    y2 = y1+ y2+ + panel1.AutoscrollPosition.Y

    These autoscrollPosition will only work when before this call we must set the AutoscrollMinsize property with max line size.

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