Re: Drawing Lines on specific panel
- From: Peter Duniho <NpOeStPeAdM@xxxxxxxxxxxxxxxx>
- Date: Wed, 26 Sep 2007 09:58:29 -0700
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
.
- References:
- Re: Drawing Lines on specific panel
- From: Kevin Spencer
- Re: Drawing Lines on specific panel
- Prev by Date: Re: Generic list and inheritance
- Next by Date: Re: Generic list and inheritance
- Previous by thread: Re: Drawing Lines on specific panel
- Next by thread: Filtering ListViewItems
- Index(es):
Relevant Pages
|