Automatically Resizing Control buttons at runtime


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 4 of 4

Thread: Automatically Resizing Control buttons at runtime

Hybrid View

  1. #1
    Daniel Noack Guest

    Automatically Resizing Control buttons at runtime


    I am having a problem with a program in which I have to create a group of
    option button controls at runtime and put them in the same frame container.
    The problem is resizing the individual option buttons depending on the size
    of the caption that each needs to display which can vary a lot. With a label
    it is easy by using the autosize and wordwrap properties of the control but
    I am not sure how to set the option buttons to the appropriate width and
    height depending on the size of their caption property. Does anyone know
    of a way to automatically resize option button controls at runtime depending
    on the size of the caption they have to display ??????
    Please help....

  2. #2
    Bernie Guest

    Re: Automatically Resizing Control buttons at runtime


    "Daniel Noack" <dnoack@fbrice.com.au> wrote:
    >
    >I am having a problem with a program in which I have to create a group of
    >option button controls at runtime and put them in the same frame container.
    >The problem is resizing the individual option buttons depending on the size
    >of the caption that each needs to display which can vary a lot. With a label
    >it is easy by using the autosize and wordwrap properties of the control

    but
    >I am not sure how to set the option buttons to the appropriate width and
    >height depending on the size of their caption property. Does anyone know
    >of a way to automatically resize option button controls at runtime depending
    >on the size of the caption they have to display ??????
    >Please help....


    Hi,

    There is an API called GetTextExtentPoint32() you can use to get the height
    and width of a specific string. If you're not familiar with API's there is
    a simplier approach. Put an invisible label somewhere on the form and set
    AutoSize to True. Ensure the font used is the same type and size as with
    the button. Set the labels caption with the string and read the width property.

    Bernie


  3. #3
    Caroline Guest

    Re: Automatically Resizing Control buttons at runtime


    Daniel, here is another solution that might work for you. I don't like the
    way option button/checkbox captions are grayed when disabled, unlike other
    labels on my forms, so I omit the captions, set the size to 200x200 and align
    labels to replace the captions. The labels have the same index property
    as the corresponding button or checkbox so when one receives focus the program
    underlines the label.

    Caroline

    "Bernie" <magnus.bernroth@rejlers.se> wrote:
    >
    >"Daniel Noack" <dnoack@fbrice.com.au> wrote:
    >>
    >>I am having a problem with a program in which I have to create a group

    of
    >>option button controls at runtime and put them in the same frame container.
    >>The problem is resizing the individual option buttons depending on the

    size
    >>of the caption that each needs to display which can vary a lot. With a

    label
    >>it is easy by using the autosize and wordwrap properties of the control

    >but
    >>I am not sure how to set the option buttons to the appropriate width and
    >>height depending on the size of their caption property. Does anyone know
    >>of a way to automatically resize option button controls at runtime depending
    >>on the size of the caption they have to display ??????
    >>Please help....

    >
    >Hi,
    >
    >There is an API called GetTextExtentPoint32() you can use to get the height
    >and width of a specific string. If you're not familiar with API's there

    is
    >a simplier approach. Put an invisible label somewhere on the form and set
    >AutoSize to True. Ensure the font used is the same type and size as with
    >the button. Set the labels caption with the string and read the width property.
    >
    >Bernie
    >



  4. #4
    Neelam Guest

    Re: Automatically Resizing Control buttons at runtime


    Dear Daniel,

    U can set width and height of ur control same as height of ur user control.
    In user control resize event.

    Neelam

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center