Resizing of Labels in Controls
-
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
-
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
Navaneeth How to use google | Ask smart questions
-
Navaneeth How to use google | Ask smart questions
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?
-
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?
-
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?
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 :)
-
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 :)
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