|
The min, max size of form is fixed.
How to add possibility to scroll vertically and horizontally, so I can see everything what has been painted?
I tried for the panel : this.panel1.Dock = System.Windows.Forms.DockStyle.Fill;
and for the form:
this.AutoScrollMinSize = new Size(this.panel1.Width, this.panel1.Height);
but this isn't gonna to work, it returns size of panel before paint operation, after paint panel'll be longer.
I can set manually this.AutoScrollMinSize = new Size(999999,99999) but this is pointless too, because scrolling will be too much.
How to do it automatically, so this.AutoScrollMinSize will know what is the size of Panel after drawing, I can't do it manually because in this example I don't know how big this panel should be?
but this isn't gonna to work, it returns size of panel before paint operation, after paint panel'll be longer.
I can set manually this.AutoScrollMinSize = new Size(999999,99999) but this is pointless too, because scrolling will be too much.
How to do it automatically, so this.AutoScrollMinSize will know what is the size of Panel after drawing, I can't do it manually because in this example I don't know how big this panel should be?
RobertPosted Oct 24, 2009, 9:42 AM
Form has 300x300 fixed size, autoscrool=true and autoscrollmargin=0;0.
Panel autosize and anchor to all.
And working code:
jingePosted Oct 24, 2009, 8:57 AM
I come up with an idea.
First create a user control in which we draw our staffs.
Note that, when you draw in the usercontrol, make sure increase the usercontrol as necessary. This might be difficult as you may need to use HitTest to make sure if the drawings are out of the usercontrol's boundary.
At last, add the usercontrol to the panel. Set AutoScroll to true.
It would be easy to say, but much hard to implement. I'm afraid.
Thank you...
RobertPosted Oct 24, 2009, 8:49 AM
This is project http://www.sendspace.com/file/p14b5a , only form and panel and this drawing stuff.
Maximum size for form is 0;0 so you can resize it and see what have been done, but I want fixed size for form 300;300 (disallow resize), and show scrollbars vert. and horiz.
jingePosted Oct 24, 2009, 8:45 AM
Kirtan PatelPosted Oct 24, 2009, 8:42 AM
i m also looking answer for that question but solution in not there in link you provided
jingePosted Oct 24, 2009, 8:35 AM
http://social.msdn.microsoft.com/Forums/en-US/winforms/thread/417a5a7f-c2db-4f88-9956-259fe27ebfa7