locked
Controls Rearranged Inside a UserControl c# RRS feed

  • Question

  • Environment: ClickOnce deployed Windows Forms app developed with Visual C# 2010 Express.

    Situation: My main form is divided by SplitContainers.  Inside one of the SC panels is a UserControl (#1) that contains various controls including a TableLayoutPanel that contains other UserControls (#2).  UC2 contains labels, textboxes, and a button.  See the green box entitled "First Person" in the first ("Correct") screenshot below as an example of UC2.  I want UC1 and its contents to remain a fixed size.

    On computer 1, it renders correctly as shown in the "Correct" screenshot.  On computer 2, it renders incorrectly as shown in the 2nd screenshot ("Wrong").  That includes UC2 apparently shrinking such that the contained controls no longer fit vertically and the "?" button in the upper right corner moves to the left.

    I tried to recreate the problem on computer 1 by resizing the form and by changing every screen setting I can, including the resolution.  While this has consequences, none of them include rearranging the controls inside UC2 the way they do on computer 2.  I am not very knowledgeable about control resizing/etc.  I'm writing to ask what I should be looking at. 

    • The SC panels have AutoScroll = true.
    • UC1 has AutoSize = false.
    • The TLP is anchored to the Top|Left of UC1 and has AutoSize = false. 
    • UC2 spans 3 panels of the TLP and is anchored on all 4 sides and has AutoSize = false and AutoScroll = false. 
    • The labels and textboxes inside UC2 are anchored Top|Left, while the "?" button (which moves the most) is anchored Top|Right. 



    • Edited by Cincy Steve Friday, December 5, 2014 7:42 PM
    Friday, December 5, 2014 7:30 PM

Answers

  • Yea font can be the problem, but somebody who uses Windows Forms uses mostly most common fonts and I see you use them as well. The chance that fonts are the problem is if those are not available on the user computer. But what I see from yours they look to me just standard.

    Yes I mean using the anchor in the best way to keep everything inline while resizing. The first time you think you do it wrong, after 3 times doing it wrong, your mostly see the benefit of it.

    (You can set them using the designer).

    Be aware that some tried to change the font size while the user was resizing. The result is that it gives views like you show. Like I wrote before, you cannot and must not influence the personal settings of the user.

     

    Success
    Cor

    • Proposed as answer by Carl Cai Monday, December 8, 2014 2:55 AM
    • Marked as answer by Cincy Steve Monday, December 8, 2014 2:24 PM
    Saturday, December 6, 2014 8:26 PM
  • Cor - Thanks again for responding.  Clearly, Font variability is the root of my problem.  I am continuing to find info that explains how to manage Fonts when there are UserControls, including your feedback.  Among the more helpful things I've found are these:

    http://msdn.microsoft.com/en-us/library/ms229605(v=vs.110).aspx

    http://weblogs.asp.net/KDente/394499

    If you happen to know of other documentation that integrates everything of importance on this topic, please let me know.  I have fixed my immediate problem, but am looking for confidence that I have an approach that work in other contexts.  I think I need clarity on the impact of Fonts and Resizing on Forms, UserControls, Panels, TableLayoutPanels, and SplitContainers, including how those cascade to the children controls of these containers.

    Thanks.

    Hello Cincy,

    I found that you have posted another thread for font issues in windows form applications.

    We will focus on that thread to help you deal with the font issues.

    Regards.

    Carl


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    • Marked as answer by Cincy Steve Monday, December 8, 2014 2:25 PM
    Monday, December 8, 2014 2:57 AM

All replies

  • A windows forms control is just an old Control likewise it did exist in Windows 3.11

    Try to avoid doing things with resolutions, left, top or whatever, the result will mostly be horrible if the user has done personalization likewise can be done on the current windows OS systems. 

    There are two good properties to get it right that are the dock and the anchor. 

    I think especially the anchor is the one you have to look at.

    http://msdn.microsoft.com/en-us/library/system.windows.forms.control.anchor(v=vs.110).aspx


    Success
    Cor

    Saturday, December 6, 2014 8:18 AM
  • Cor - Thanks for your response.  But I'm not sure I understand what you are suggesting: 

    1. I only looked at resolution to see if that could be the source of my problem.  It doesn't seem to be.
    2. With regard to Dock and Anchor, are you saying that those are the primary properties I SHOULD use to manage resizing?  It seems to me that they are, and so that's what I've tried to do.  What's confusing me is your statement to "avoid doing things with left, top or whatever."

    My son (a graphic designer) suggested that my underlying problem is Font management.  After a little more testing, that seems to be the case.  As I've adjusted the Fonts in the app in various ways on computer 1, I started to see the problem that's on computer 2, though I haven't been able to exactly replicate the outcome.

    I've been looking in the MSDN Library and elsewhere for a clear explanation of how to manage/set Fonts (including text size) in my app so that the way the app renders is not affected by the external defaults set on the computer.  But what I'm finding is leave lots of questions.  For example, how can I tell if an ambient property (Font) is "not set", especially when it appears to be in Visual Studio?  Can you point me to some clear and thorough explanation?

    Also, I've been trying to change the default Font on my Windows 8.1 computer, without luck.  I can change the text size, but haven't found how to change the Family Name.  I even found a YouTube posting that implied I'd have to manually change the Registry.  Surely that's not true.  Can you point me to info that shows how to change my default Font Family Name?

    Thanks.  Steve



    • Edited by Cincy Steve Saturday, December 6, 2014 6:41 PM
    Saturday, December 6, 2014 6:39 PM
  • Yea font can be the problem, but somebody who uses Windows Forms uses mostly most common fonts and I see you use them as well. The chance that fonts are the problem is if those are not available on the user computer. But what I see from yours they look to me just standard.

    Yes I mean using the anchor in the best way to keep everything inline while resizing. The first time you think you do it wrong, after 3 times doing it wrong, your mostly see the benefit of it.

    (You can set them using the designer).

    Be aware that some tried to change the font size while the user was resizing. The result is that it gives views like you show. Like I wrote before, you cannot and must not influence the personal settings of the user.

     

    Success
    Cor

    • Proposed as answer by Carl Cai Monday, December 8, 2014 2:55 AM
    • Marked as answer by Cincy Steve Monday, December 8, 2014 2:24 PM
    Saturday, December 6, 2014 8:26 PM
  • Cor - Thanks again for responding.  Clearly, Font variability is the root of my problem.  I am continuing to find info that explains how to manage Fonts when there are UserControls, including your feedback.  Among the more helpful things I've found are these:

    http://msdn.microsoft.com/en-us/library/ms229605(v=vs.110).aspx

    http://weblogs.asp.net/KDente/394499

    If you happen to know of other documentation that integrates everything of importance on this topic, please let me know.  I have fixed my immediate problem, but am looking for confidence that I have an approach that work in other contexts.  I think I need clarity on the impact of Fonts and Resizing on Forms, UserControls, Panels, TableLayoutPanels, and SplitContainers, including how those cascade to the children controls of these containers.

    Thanks.

    • Proposed as answer by Carl Cai Monday, December 8, 2014 2:55 AM
    Sunday, December 7, 2014 5:09 PM
  • Cor - Thanks again for responding.  Clearly, Font variability is the root of my problem.  I am continuing to find info that explains how to manage Fonts when there are UserControls, including your feedback.  Among the more helpful things I've found are these:

    http://msdn.microsoft.com/en-us/library/ms229605(v=vs.110).aspx

    http://weblogs.asp.net/KDente/394499

    If you happen to know of other documentation that integrates everything of importance on this topic, please let me know.  I have fixed my immediate problem, but am looking for confidence that I have an approach that work in other contexts.  I think I need clarity on the impact of Fonts and Resizing on Forms, UserControls, Panels, TableLayoutPanels, and SplitContainers, including how those cascade to the children controls of these containers.

    Thanks.

    Hello Cincy,

    I found that you have posted another thread for font issues in windows form applications.

    We will focus on that thread to help you deal with the font issues.

    Regards.

    Carl


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    • Marked as answer by Cincy Steve Monday, December 8, 2014 2:25 PM
    Monday, December 8, 2014 2:57 AM
  • Thanks, Carl.  Your response to my other thread was just what I needed.

    Steve

    Monday, December 8, 2014 2:24 PM