Results 1 to 8 of 8

Thread: How to resize a control up to the bottom of a form?

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Feb 2012
    Posts
    616

    How to resize a control up to the bottom of a form?

    Let's say, we have a form which should have different dimensions depend of display resolution. That form has starting resolution of 1024x768. There's a listview control placed on position 10, 300 with height property = 440. But, if you change screen resolution to, let's say, 1440x900, we'll get a part of unused space below the listview control. I'd like to know, what's the best way to resize a control? How to change height property to fits on any resolution? But, there's an important moment in that story. Starting position of a control couldn't be changed. In our case, starting position of our control should stay at 10,300.

  2. #2
    Super Moderator dday9's Avatar
    Join Date
    Mar 2011
    Location
    South Louisiana
    Posts
    11,753

    Re: How to resize a control up to the bottom of a form?

    Set the Anchor property of the control to include the bottom. By default the anchor is left or top, you should change it to left or top or bottom. If you want to it expand horizontally as well then set the anchor to include all sides: bottom, left, right, or top.
    "Code is like humor. When you have to explain it, it is bad." - Cory House
    VbLessons | Code Tags | Sword of Fury - Jameram

  3. #3
    Smooth Moperator techgnome's Avatar
    Join Date
    May 2002
    Posts
    34,537

    Re: How to resize a control up to the bottom of a form?

    You can also play with the Dock property for some added fun.

    -tg
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

  4. #4

    Thread Starter
    Fanatic Member
    Join Date
    Feb 2012
    Posts
    616

    Re: How to resize a control up to the bottom of a form?

    The reason why I put previous question was related with my unsatisfactory with results of Anchor method for solving of this problem. Starting top,left position of the control is being changed. I'd prefer a code which calculate how many pixels we have from the top,left position of a control up to the bottom of our window. That value could be assigned to .height property.

  5. #5
    Smooth Moperator techgnome's Avatar
    Join Date
    May 2002
    Posts
    34,537

    Re: How to resize a control up to the bottom of a form?

    What previous question?

    Not sure what the issue is. I do this all the time. Dock the control to the bottom of the form... that takes care of the width... then anchor the top... then as the form resizes, the top stays put, relative to the top of the form, and resizes itself based on the rest of the form.

    -tg
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

  6. #6

    Thread Starter
    Fanatic Member
    Join Date
    Feb 2012
    Posts
    616

    Re: How to resize a control up to the bottom of a form?

    I already did that but control lost its top-left position. That's not what I wanted to get
    P.S. of course, I only used bottom Anchor value.

  7. #7
    Super Moderator dday9's Avatar
    Join Date
    Mar 2011
    Location
    South Louisiana
    Posts
    11,753

    Re: How to resize a control up to the bottom of a form?

    The best way to understand how docking and anchoring works is to play with them, but from what it sounds like, all you need to do is set your anchor to: Bottom or Left or Right or Top. Do this in the designer by selecting all the anchors.
    "Code is like humor. When you have to explain it, it is bad." - Cory House
    VbLessons | Code Tags | Sword of Fury - Jameram

  8. #8
    Smooth Moperator techgnome's Avatar
    Join Date
    May 2002
    Posts
    34,537

    Re: How to resize a control up to the bottom of a form?

    Quote Originally Posted by Goshx View Post
    I already did that but control lost its top-left position. That's not what I wanted to get
    P.S. of course, I only used bottom Anchor value.
    That clearly shows you don't understand how it works. you don't anchor the bottom. you dock it, you anchor the TOP. When you anchor and edge, you're pinning it to that spot, saying "Don't Move!" ... so if you have the top left at 0, 100 and you anchor the top and the left, the top left will stay put. The control still won't resize. So if you then anchor the right, the right side will then expand/contract in relation to the right of the form. IF the control is 100 wide and the form is 150... there will always be a gap of 50 between the control and the form.... no matter how large the form gets.

    -tg
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

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