Re: Drawing Lines on specific panel



Gidi wrote:
Thanks Kevin,

the problem is that my form heightis smaller then my panel height, so i have to scroll the panel up and down to see all it's content. now when i scroll the panel the paint event starts again, but not from point (0,0) of the orginal panel but from the point that the scroll stopped and i don't want that. I want to draw the lines one time from height = 0 to panel's height, without calling the drawing line again after scrolling.

how can i do it?

As has been mentioned, in the Windows display paradigm requires that you always respond to the Paint event, drawing your image each time.

You can cache your drawing to a bitmap if you want persistence without having to go through all of the drawing code each time, but a) this is often not actually required in order to achieve good performance, and b) it won't address what appears to be your _actual_ question.

Specifically, it sounds as though you are having trouble with the scrolling aspect of the drawing. You need to handle this yourself, regardless of how you actually do the drawing. The basic issue is that the drawing origin of the control doesn't actually change according to the scrollbar position.

You can address this either by using the Panel's AutoScrollPosition property to offset your own drawing (either explicitly or by changing the Transform property of the Graphics object you're using for drawing), or you can just "nest" your custom-drawn Panel inside a different Panel or UserControl that handles the actual scrolling (in that way, you'll always be drawing relative to your custom-drawn Panel's origin, and that Panel will be moved as appropriate within the control that's actually scrolling.

Pete
.



Relevant Pages

  • Re: Flowlayout, JPanel and JScrollPane: Scrolling vertically impossible?
    ... >> JScrollPane using FlowLayout. ... >> enable wrapping, and when components inside the panel go out of view, ... > scrolling). ... > (And therefore the preferredSize value returned by the panel would ...
    (comp.lang.java.gui)
  • Re: Dialog Management Scrolling WAS Left & Right Scrolling in ISPF
    ... Making the panel width larger than 80 characters will cause an error if someone attempts to display the panel on a regular 80 width screen size. ... Dialog Management Scrolling WAS Left & Right Scrolling in ISPF ... My thought was that I would have to build a Panel table larger than the traditional 80 Character width. ... For IBM-MAIN subscribe / signoff / archive access instructions, ...
    (bit.listserv.ibm-main)
  • Re: I have an issue with an image getting corrupted upon scroll in a panel.
    ... The GDI+ FAQ shows you how to save without compression. ... corrupted and disappears upon scrolling within a panel. ...
    (microsoft.public.dotnet.framework.drawing)
  • Re: I have an issue with an image getting corrupted upon scroll in a panel.
    ... the code project to come up with an overlayed map image, ... corrupted and disappears upon scrolling within a panel. ... If there is no way around this picturebox in a panel redraw issue; ...
    (microsoft.public.dotnet.framework.drawing)
  • Re: Printing of shapes in GDI+
    ... Probably your easiest method will be to do all of your drawing, ... Answer those GDI+ questions with the GDI+ FAQ ... > I am drawing some shapes on the scrollable panel using GDI+. ...
    (microsoft.public.dotnet.framework.drawing)