How do I resize a panel at runtime?
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
Re: How do I resize a panel at runtime?
Quote:
Originally Posted by Richard210363
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
You 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.
Code:
// 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
Re: How do I resize a panel at runtime?
Thanks for the reply.
I'll give it a go.