Home > Controls, Visual Basic > Control Freak!

Control Freak!

The gears from an egg timer, showing the Lever...

Image via Wikipedia

Today I am going to tell you about some of the lesser-known (albeit useful) Windows Forms Controls.  You can click on the names of the controls

1. The Timer control – Though most experienced VB users will know about this control, it is still worth noting.  The timer object will fire its “Tick” event once every Interval milliseconds.  Thus, if you want a label to scroll upwards, use this code:

'In New() or Form1_Load()

'The timer should fire every 10 milliseconds.

Timer1.Interval = 10

'Start the timer.


'In Timer1_Tick.

'Move the label upwards.

Label1.Location = New Point(Label1.Location.X, Label1.Location.Y - 1

2. NotifyIcon – This useful control allows you to manipulate your very own icon in the Windows Task Bar (see below).  This is useful for getting a user’s attention.

To show a balloon with a NotifyIcon:

NotifyIcon1.BalloonTipText = "Whatever the balloon should say."

NotifyIcon1.BalloonTipTitle = "The title of your notification."

NotifyIcon1.BalloonTipIcon = ToolTipIcon.Error 'Can be Error, Info, None, or Warning.

NotifyIcon1.ShowBalloonTip(15) 'Replace 15 with the amount of time, in milliseconds, to show the balloon.

3. BackgroundWorker – This nifty control will run a process seperately from the current thread. This is useful, say, if you have a large task that takes a long time, and you don’t want it to affect the normal performance of the program.  Here is the code to use:

'In BackgroundWorker1.DoWork()

'Perform some large task.

For x = 1 To 100000

Dim w = x * x - 1 / x + 1 Mod 15 + x * 7 - x * 100


4. ToolTip – This control shows a yellow “info box” when used properly, like so:

While you cannot (to my knowledge) show images in the VB tooltip, you can show a tooltip by setting your control’s “Tooltip on ToolTip1” property to your message. Then, whenever the user hovers over the control, your tooltip is displayed. You can also display a custom tooltip like so:

ToolTip1.Show("Your Message Here!", Me, MousePosition, 5) 'Set 5 to how long you want the tooltip to show, in milliseconds.

5. SplitContainer – With this container, you can neatly divide the form into two or more parts, like so:

Hope you learned!  I’ll bid you adieu until tommorow.  My parting Q: What is your favorite Windows Form Control?

  1. LinuxGuy
    August 26, 2011 at 4:57 PM

    My favorites are the Krypton Toolkit and the QIOS Devsuite (both are free)
    QIOS includes things like a windows ribbon.

  1. No trackbacks yet.

Your comment:

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: