Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Managed C++/CLI
  4. Resizing of Labels in Controls

Resizing of Labels in Controls

Scheduled Pinned Locked Moved Managed C++/CLI
winformstutorialquestion
6 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • C Offline
    C Offline
    cherrymotion
    wrote on last edited by
    #1

    Hi, can somebody pleas tell me, how to correctly resize controls. I made up a Windows Forms Control Library Projekt for a simple "status-line" control, with some text for picture information (labels). The control has to be able to be dynamically resized (f.e. when user stretches the window of the parent form). But I do not come up with how to manage that. I thought I can do it with the scale-function, but somehow alway just the panels are scaled (the text-labels are on two different panels->upper and lower), the text-size of the labels remain in original size and so can no longer be shown correctly. Why is that? I mean, when I scale a whole control, the scale function should scale all, or not? I also tried with the "Resize-Event", so that I shrink /grow the labels manually, but it also didn't work. And is there an opportunity to find over the Resize-Event, how MUCH the window grew / shrank - I think you should have a factor to inherit the growth on somehow. Maybe my mistake is just from false properties, but how would you pros manage that? Thanks in advance, cherry

    N 1 Reply Last reply
    0
    • C cherrymotion

      Hi, can somebody pleas tell me, how to correctly resize controls. I made up a Windows Forms Control Library Projekt for a simple "status-line" control, with some text for picture information (labels). The control has to be able to be dynamically resized (f.e. when user stretches the window of the parent form). But I do not come up with how to manage that. I thought I can do it with the scale-function, but somehow alway just the panels are scaled (the text-labels are on two different panels->upper and lower), the text-size of the labels remain in original size and so can no longer be shown correctly. Why is that? I mean, when I scale a whole control, the scale function should scale all, or not? I also tried with the "Resize-Event", so that I shrink /grow the labels manually, but it also didn't work. And is there an opportunity to find over the Resize-Event, how MUCH the window grew / shrank - I think you should have a factor to inherit the growth on somehow. Maybe my mistake is just from false properties, but how would you pros manage that? Thanks in advance, cherry

      N Offline
      N Offline
      N a v a n e e t h
      wrote on last edited by
      #2

      Read about Anchor[^]. :)

      Navaneeth How to use google | Ask smart questions

      C 1 Reply Last reply
      0
      • N N a v a n e e t h

        Read about Anchor[^]. :)

        Navaneeth How to use google | Ask smart questions

        C Offline
        C Offline
        cherrymotion
        wrote on last edited by
        #3

        I know about the anchoring, and I used it. But as I said, the control ist anchored nicely, but the labels (text) remain as big as they are. There are so many attributes concerning "sizing", so that I maybe always set on property not correctly. How does anchoring, docking, autosizing and scaling work together - I found there no good descriptions in the web. I found that http://msdn.microsoft.com/en-us/library/ms171729.aspx[^] You see, they write "Note The Label control is the exception to this rule. When you set the value of a docked Label control's AutoSize property to true, the Label control will not stretch." But how do I get the stretching then?

        L 1 Reply Last reply
        0
        • C cherrymotion

          I know about the anchoring, and I used it. But as I said, the control ist anchored nicely, but the labels (text) remain as big as they are. There are so many attributes concerning "sizing", so that I maybe always set on property not correctly. How does anchoring, docking, autosizing and scaling work together - I found there no good descriptions in the web. I found that http://msdn.microsoft.com/en-us/library/ms171729.aspx[^] You see, they write "Note The Label control is the exception to this rule. When you set the value of a docked Label control's AutoSize property to true, the Label control will not stretch." But how do I get the stretching then?

          L Offline
          L Offline
          led mike
          wrote on last edited by
          #4

          cherrymotion wrote:

          But how do I get the stretching then?

          Why do you need a label control to stretch more than what is required to display the text?

          C 1 Reply Last reply
          0
          • L led mike

            cherrymotion wrote:

            But how do I get the stretching then?

            Why do you need a label control to stretch more than what is required to display the text?

            C Offline
            C Offline
            cherrymotion
            wrote on last edited by
            #5

            Ok, I have it now. Something went wrong with my Auto-Size properties. But can anyone tell me how to find out from the Control.Resize-Event, with which factor the Form has been resized? I have to calculate the space for my pictures an let them dynamically grow and shrink, but for that I'm sure there is an opportunity to get that factor, isn't it? Otherwise maybe I should save a rectangle with the current form size and set it then in relation to the "grown" window parent. But a "resize-factor" would be much nicer I think... Thanks for your answers, sometimes it is not easy :)

            L 1 Reply Last reply
            0
            • C cherrymotion

              Ok, I have it now. Something went wrong with my Auto-Size properties. But can anyone tell me how to find out from the Control.Resize-Event, with which factor the Form has been resized? I have to calculate the space for my pictures an let them dynamically grow and shrink, but for that I'm sure there is an opportunity to get that factor, isn't it? Otherwise maybe I should save a rectangle with the current form size and set it then in relation to the "grown" window parent. But a "resize-factor" would be much nicer I think... Thanks for your answers, sometimes it is not easy :)

              L Offline
              L Offline
              Luc Pattyn
              wrote on last edited by
              #6

              Hi, The Form class already has 4 events regarding resizing: Resize, ResizeBegin, ResizeEnd, SizeChanged. That should cover it I'd say. However you have to keep the current Size somewhere in order to calculate growth/shrink. :)

              Luc Pattyn [Forum Guidelines] [My Articles]


              The quality and detail of your question reflects on the effectiveness of the help you are likely to get. Show formatted code inside PRE tags, and give clear symptoms when describing a problem.


              modified on Friday, May 22, 2009 3:48 PM

              1 Reply Last reply
              0
              Reply
              • Reply as topic
              Log in to reply
              • Oldest to Newest
              • Newest to Oldest
              • Most Votes


              • Login

              • Don't have an account? Register

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • World
              • Users
              • Groups