Windows Forms and Controls

A Closer Look at the Properties

Lets look at some of the properties you might not be familiar with.

Anchor: Relating to the controls this is how you can set the controls to anchor themselves to a given area. If you start the project (F5 or click the Video-like play button) and maximize the form you will see the label moving over to the top-left of the form, the textbox to the top-right and the two buttons to the bottom-right. The Accept button will not overlap the other button just get as close as it can keeping any distance between itself and any controls nearer to that anchor position.

Font: A familiar property but setting it on the form only (in this case) automatically sets all the controls on it to the same font. Of course you can set different fonts for the controls if you wish (not a good idea).

GridSize: A very handy one. With the above settings you will see more lines on the form and have more room to work with controls and the snapping effect you get by default. In VB6 I always used to turn off snapping for more accuracy but this new option means you can improve accuracy and keep the snapping which is very desirable.

Location: Applicable to forms and controls but you would normally just be setting controls. When using the designer it won’t be of much significance but worth noting if you ever want to set it in code.

MinimumSize: Try resizing your form as small as possible while running it. Because of the MinimumSize setting you can’t get it any smaller than 200x 200. Useful for ensuring certain parts of your form won’t disappear. I won’t describe Size as it’s a similar format but describes the size of the form/controls at runtime and again is more pertinent in code.

Opacity: If you start the project (F5 or click the Video-like play button) and look at your lovely creation. Whats this? It’s almost see through. Well I’m sure you’ve guessed that this is related to the opacity percentage we set. Not much use but hey it looks cool. Be careful not to overuse properties you think are cool but that you’re intended user might find very annoying given time. One possible use would be to increment the opacity gradually in code to give the form a fade-in effect as it loads.

TextAlign: Hardly an unfamiliar term but you’ll notice that setting it for the label and button controls it allows you to click on a visual position which again is a nice little touch.

You might also like...

Comments

About the author

Brian O'Connell Ireland

Microsoft Certified Applications Developer with 10 years experience developing web based applications using asp, asp.net for a Local Authority in Dublin. Clings to a firm belief that a web appli...

Interested in writing for us? Find out more.

Contribute

Why not write for us? Or you could submit an event or a user group in your area. Alternatively just tell us what you think!

Our tools

We've got automatic conversion tools to convert C# to VB.NET, VB.NET to C#. Also you can compress javascript and compress css and generate sql connection strings.

“Walking on water and developing software from a specification are easy if both are frozen.” - Edward V Berard