Tag Archives: Visual Basic

Fixing the default of the .Net Label’s AutoSize property


This is a story about creating form applications using Visual Basic and Visual C#.

Have you ever wished that the default for the AutoSize property of labels was False? While there might be cases where you create them with AutoSize = True, in my company, we use AutoSize = False. However, it’s cumbersome to set the property every time you paste a label. So, the idea behind this code is to create labels with the AutoSize default value set to False. This has been confirmed using Visual Studio 2010 and Visual Basic.

In Visual Studio Professional Edition, you can create inherited controls. In the Express Edition, you couldn’t create inherited controls from the start, as far as I recall. In that case, you first create an inherited class.

The class to inherit is System.Windows.Forms.Label. A common approach here is to use the property window of the control’s designer screen to set AutoSize to False (though nothing appears in the designer screen, the property window is usable). However, for the Label control, things get tricky, as it reverts to AutoSize = True when actually pasted onto a form. To tackle this, display the code and add the following snippet.

Continue reading Fixing the default of the .Net Label’s AutoSize property

VBS: How to get the folder which contains the .vbs file itself


This is a method to retrieve the folder containing VBS files using VBS. This allows you to perform operations using the absolute path to the folder containing VBS files.

Continue reading VBS: How to get the folder which contains the .vbs file itself