Previous | Index | Next 

[PRB] VB.NET controls are taller than the original VB6 control

You might notice that some VB.NET controls – most notably TextBox and ComboBox controls, and their variants – are taller than they were in the original VB6 application.

The reason is, by default VB.NET controls accommodate for their font’s height, therefore a large font may force the control to be taller than the value assigned to its Height property. The easiest solution is therefore to reduce the default size of the font used for these controls. Basically, there are two simple ways to achieve such a result.

First, you can use a project-level or form-level ReplaceFontSize pragma to decrease the size of a specific font, as in this example:

     '## project:ReplaceFontSize Arial, 10, Arial, 9

Second, you can use a PostProcess pragma to decrease the size of all the fonts used in the code-behind portions your forms, regardless of the font name or the original font size. For example, the following pragma subtracts 1 point to the original height of all the Font objects assigned to the Font property

     '## PostProcess "(?<=\.Font = New System\.Drawing\.Font\(.+?,\s+[0-9.]+)!", "- 1"

Notice that both these techniques modify the font size of all the controls on your forms, not just TextBox and ComboBox controls. In general, this is desirable because the result is a more consistent user interface.

 

Previous | Index | Next