|
-
September 22nd, 2003, 05:34 AM
#1
Draw graphics outside client-area?
Hi
I have a panel (with auto-scroll = true) that I make dynamic drawings in. When I draw something inside the size of the panel everything is fine. But if something is drawn outside of the panel-size the scrolling doesn´t show. The scroll only shows if I draw (e.g. make visible and set a location) some windows-form-control (e.g. LinkedLabel) outside the area. But then the drawn image that should be outside the area isn´t there when I scroll. And when I scroll back the image that was there before now is gone...
I understand that it has to be some problem about how I update the image but I haven´t been able to fix it. I want to "draw" a big drawing and then be able to scroll around to see the whole picture.
I make all my drawings in Paint-events, is this wrong? It´s a regular windows application. How should I solve this problem?
Thanks in advance.
/Tobbe
(Sorry for my bad english...)
Example on my problem (only importent code):
public class Form1 : System.Windows.Forms.Form
{
private System.Windows.Forms.Panel panel1;
private System.Windows.Forms.LinkLabel linkLabel1;
public Form1()
{
InitializeComponent();
this.linkLabel1.Location = new System.Drawing.Point(1500, 150);
}
static void Main()
{
Application.Run(new Form1());
}
private void panel1_Paint(object sender, System.Windows.Forms.PaintEventArgs e)
{
e.Graphics.DrawLine(new Pen(Brushes.Black, 2.0f),20,20,1500,250);
}
Last edited by d98tp; September 22nd, 2003 at 05:42 AM.
-
February 18th, 2004, 01:53 PM
#2
Just in case you're still having this problem or if anyone else searches for a similar problem: For a Control that has the autoscroll property, it determines whether or not to show the scroll bars by either having a control outside the visiable bounds OR by the AutoScrollMinSize property.
In this specific case, you'd determine the size of the image being drawn and set the AutoScrollMinSize to that size. Then you'd treat the drawing in your paint event the normal way (i.e.) you'd draw a portion of the image starting at the scroll offset to width and height of the control.
It took me a while to dig up the meaning of AutoScrollMinSize and it's relation to autoscroll.
bytz
--This signature left intentionally blank--
-
August 30th, 2004, 06:22 PM
#3
Re: Draw graphics outside client-area?
Thanks for the info.
I was getting frustrated
-
September 21st, 2005, 01:09 PM
#4
Re: Draw graphics outside client-area?
This was really helpful. Thank you for posting the response.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|