CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 7 of 7
  1. #1
    Join Date
    Aug 2000
    Location
    Essex, Uk
    Posts
    1,214

    [RESOLVED] Control Resizing

    Hi All,

    In VB6 there was a Method called resize on a form that would allow me to programatically change the width, height etc of controls on a form based on the forms dimensions. Typically used when a user Drags the edge of a form to make it larger.

    I could not find a Resize event on my form (Winforms).

    It appears that I need to use something like a FLowLayout Control. So I have placed a flowlayout control on my form and then placed a treeview and grid control on that. However, I still seem not to be able to resize the control accourdingly.

    COuld someone please point me in the direction to resize controls on a form during runtime when the user decides to manually increase or decrease the size of the form.
    If you find my answers helpful, dont forget to rate me

  2. #2
    Join Date
    Mar 2004
    Location
    33°11'18.10"N 96°45'20.28"W
    Posts
    1,808

    Re: Control Resizing

    use either the dock property, or anchor property to automagically layout your control.

  3. #3
    Join Date
    Oct 2004
    Location
    Rocket City
    Posts
    220

    Re: Control Resizing

    In VS 2005, most 'Winform' controls have a Resize event which is accessed in the Properties window. A System.Windows.Forms.Form also has ResizeBegin and ResizeEnd events.

  4. #4
    Join Date
    Nov 2006
    Location
    North Bend, WA
    Posts
    487

    Smile Re: Control Resizing

    I've used both approaches. I'll always try to use multiple panels and use anchors until things just don't work the way I want, and then I'll switch to the "do it my way for this UI" approach. Of course, I usually just make my dialogs big and not resizable.

    Maybe you missed the Resize event (in VS 2005, it's grouped with the Property Changed events).

  5. #5
    Join Date
    Aug 2000
    Location
    Essex, Uk
    Posts
    1,214

    Re: Control Resizing

    Hi All,

    I've got the controls on 2 flowlayout controls. and they stay positioned. When resizing the form I cannot shrink the form to less than the default size (good), however i haven't figured out when I 'grow' the form how to increase the controls proportionally. A further problem, is if I expand the form from the Left hand edge, the controls stay in place and do not follow the left edge of the form as I'd expect.

    I Guess I need to use 'Zips' suggestion, how do I declare the ResizeBegin event in C#?
    If you find my answers helpful, dont forget to rate me

  6. #6
    Join Date
    Aug 2003
    Location
    London
    Posts
    515

    Re: Control Resizing

    Once way to have the IDE write the method signatures for you is as follows....


    Click on the properties tab in your IDE

    Click on the form you wish to resize controls for. The properties of the form are now displayed in the properties tab.

    Switch to the events for the form by clicking on the 'Lightening bolt' icon at the top of the properties tab. All form events are now displayed.

    Find the resize event in the tab. Double click in the empty space next to the event name.

    The IDE will write the method signature for that event & automatically wire up the event in your forms' InitializeComponent routine.
    If it helped, then please rate the post by clicking "Rate this post"!

  7. #7
    Join Date
    Aug 2000
    Location
    Essex, Uk
    Posts
    1,214

    Re: Control Resizing

    Thanks DMorley. So it looks as though I just need to write my own routine to do whatever I want happen and then call that routine in the correct event.
    If you find my answers helpful, dont forget to rate me

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