Click to See Complete Forum and Search --> : How do I resize a panel at runtime?
Richard210363
April 16th, 2008, 08:08 AM
Is it possible to resize a panel at run time by dragging on the edges of the panel?
Any resizing needs to be indipendant of the size of the containing form so Anchor and Dock are not suitable (I believe, I could be wrong).
Thanks for any help.
Richard
JonnyPoet
April 16th, 2008, 11:26 AM
Is it possible to resize a panel at run time by dragging on the edges of the panel?
Any resizing needs to be indipendant of the size of the containing form so Anchor and Dock are not suitable (I believe, I could be wrong).
Thanks for any help.
RichardYou need to use the mousemove delegate and to check if the mouse hits the boders of the panel then simple using the width and height property of the panel using delltaX and deltaY as the value to change size. There are different ways to do that. I would use a UserControl instead of a panel and therein you do.
// in the Fields define
private Point oldMousePosition = new Point();
// in the Mouse delegate do ( x,y is actual mousepos
Point newMousePosition = new Point(e.x,e.y );
deltaX = newMousePosition.X - oldMousePosition.X ;
deltaY = newMousePosition.Y - oldMousePosition.Y;
this.width += deltaX;
this.Height += deltaY;
oldMousePosition = newMousePosition;
Not tested but should be like that
Richard210363
April 18th, 2008, 05:55 AM
Thanks for the reply.
I'll give it a go.
codeguru.com
Copyright Internet.com Inc., All Rights Reserved.