Microsoft Communities

Welcome to WindowsClient.net | Sign in | Join

Here are some frequently asked questions about Windows Forms and their answers.

Windows Forms FAQs

What are some of the effects of localizing my forms?

Text clipping via Localization - When a localizer changes the text increases the size of the control by changing the text – will anything be clipped?

Problem: Changing the text in another language can cause elements of the UI to overlap.

Solution: There are multiple solutions for this:

  • Use AutoSize on controls that can grow as the text changes – e.g. buttons, labels, etc.
  • If the control can grow 30% and not overlap others, no additional work is necessary.
  • For controls that could obscure others when grown, use a FlowLayoutPanel or TableLayoutPanel to automatically place the controls.
Uniform OK/Cancel Buttons - When the Cancel button gets larger, does the OK button always stay the same size?

Problem: When OK and Cancel buttons are localized, it is a best practice to make sure that the localized OK and Cancel buttons are of the same size.

Solution: Put the OK and Cancel buttons in an AutoSized TableLayoutPanel with column styles set to 50% and 50% respectively. The anchors for the Ok and Cancel buttons should be set to Left|Right so they stretch from edge-edge of the cell.

Large Font/High Contrast – When the font size increases - will anything be clipped?

Problem: When the font changes, the size and locations of controls need to be adjusted in order not to clip.

Solution: Use auto scaling to dynamically change the size/location of controls.

Tabbing and Mnemonics – Have you set the tab order correctly?

Problem: Mnemonics for labels depend on the tab index being set correctly.

Solution: Tab through your dialog, play with mnemonics to ensure it is correct.

Accessibility Considerations – Do your text boxes and combo boxes have accessible names?

Problem: TextBoxes and ComboBoxes don't automagically pick up accessible names.

Solution: Some controls in windows forms pick up their accessible names from the previous item in the tab order. E.g. a text box can pick up its accessible name from the label preceding it. If you have a label which describes a text box or combo box, you should set the TabIndex of the label to be one less than the TabIndex of the text box.

Localization Considerations - Have you created a .resx file?

Problem: Hand coding UI generally causes problems for localizers. If they have a .resx file, the dialog can be opened in a resource editor such as WinRes.

Solution: Do not hand code UI, keep the YourForm.Designer.cs file around, hook up your events in a function outside of the YourForm.Designer.cs, so you can easily revist the file later using Visual Studio.



Page view counter