CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Oct 2005
    Posts
    28

    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

  2. #2
    Join Date
    Mar 2005
    Location
    Vienna, Austria
    Posts
    4,538

    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
    Jonny Poet

    To be Alive is depending on the willingsness to help others and also to permit others to help you. So lets be alive. !
    Using Code Tags makes the difference: Code is easier to read, so its easier to help. Do it like this: [CODE] Put Your Code here [/code]
    If anyone felt he has got help, show it in rating the post.
    Also dont forget to set a post which is fully answered to 'resolved'. For more details look to FAQ's about Forum Usage. BTW I'm using Framework 3.5 and you ?
    My latest articles :
    Creating a Dockable Panel-Controlmanager Using C#, Part 1 | Part 2 | Part 3 | Part 4 | Part 5 | Part 6 | Part 7

  3. #3
    Join Date
    Oct 2005
    Posts
    28

    Re: How do I resize a panel at runtime?

    Thanks for the reply.

    I'll give it a go.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured