Finding what you need in the Microsoft� Visual Studio� documentation, which has over 200,000 topics, can be a daunting task. The Doc Detective is here to help, utilizing his investigative skills to probe the depths of the documentation.

Can't find what you're looking for? Just ask - if it's in there, I'll find it for you; if it isn't, I'll let you know that as well (and tell you where else you might go to find it).

Have a question for the Doc? Send your questions for future columns to me at

Dear Doc Detective,

I am trying to deploy a product that includes a database to my end users. In my lab I am using the Express edition of SQL and the model/concept works perfectly. When I try to release this product to the end user, deployment fails on just about all the PCs I need to install to.

The issues were straightforward to fix since they were all related to the SQL engine that was missing. For beta and modeling purposes, I can work fine in labs and experimenting but I need some serious help on getting the product out of the door.

Can you recommend any method that I can use so that when end users install the product, all the necessary components are also installed? Just like when you buy a CD application from the store and install it on your PC, it works great or at least installs properly.

Any help will be appreciated!

  • Failing in Fairview

Dear Failing,

This is actually a fairly common question. Most applications have prerequisites that need to be installed on an end user's computer before the application is run. The problem is that “prerequisite” isn't a very common term, and if you don't know to search for “prerequisite” you won't find the Help topic.

I assume you are using ClickOnce deployment - the topic “How to: Install Prerequisites with a ClickOnce Application” explains how to include prerequisites (including SQL Express) with your app.

Or if you are using Windows Installer, see the topic “Application Deployment Prerequisites” for the same capabilities. Next thing you know, your end users will be installing your application just like one they buy from the store.

  • the Doc

Dear Doc Detective,

I am writing a program that logs keystrokes. I've already figured out how to get the name of the key being pressed in the KeyDown event using e.KeyCode.ToString.

My problem is that when NumLock is on, key presses return the KeyCode for the number rather than for the functions such as the arrow keys. How can I get the function values instead of the numbers?

  • Valueless in Valparaiso

Dear Valueless,

Interestingly enough the values returned by KeyCode are somewhat inconsistent. If NumLock is on, pressing the 1 key on the keyboard returns the string “D1” and pressing 1 on the numeric keypad returns “NumPad1”. If Numlock is off, pressing the End key on the keyboard or the 1 key on the numeric keyboard both return “END”.

What this means is that you can't differentiate between the keyboard and the numeric keypad unless NumLock is on. In your case, however, it sounds like you only want to capture the keys when NumLock is off and you don't care whether the key press is coming from the keyboard or keypad. If that is the case, you could simply check the state of the NumLock key and warn the user if it is on.

The Keyboard object in the My namespace can be used to check the key state in the KeyDown event as follows:

If My.Computer.Keyboard.Numlock = True Then
MsgBox("The Numlock key is on!")
MsgBox("You pressed " & e.KeyCode.ToString)
End If

In addition to getting the state of the NumLock key, the Keyboard object can also return the state of the Alt, CapsLock, Ctrl, ScrollLock, and Shift keys. You can learn more about the Keyboard object in the topic “Keyboard Members”. As the Doc always says, knowledge is Key.

  • Doctor D

Dear Doc Detective,

I'm running into issues with the behavior of a transparent label control on top of a picture box. When adding a transparent label control to a form with a background image, the label displays correctly and shows the background.

When you add a picture box control and add another transparent label on top of said picture box, the transparent label control on top of a picture box does not display correctly - the background doesn't show through. What's up with that?

  • Opaque in Opa-Locka

Dear Opaque,

What you are seeing is a known limitation of Windows Forms. Labels are transparent to their container or parent - not to the control underneath them. Windows does not support transparency so Windows Forms fake it by painting the parent's background inside the bounds of the label.

Fortunately there are a couple of ways to work around this, neither of which involves a label. The first would be to draw the text yourself in the parent form's Paint event. For information on drawing text, look for the topic “How to: Draw Text at a Specified Location”.

The other solution is to remove the PictureBox control and draw its contents in the Paint event. The topic “How to: Load and Display Bitmaps” explains how to draw an image on a form.

Either solution will allow your floating label to have the correct transparent behavior.

  • Doc D

Dear Doc Detective,

I have a Label control of a fixed size. When we localize the application into other languages, the localized string is sometimes too long for the allotted space.

Our solution is to use the GetPreferredSize method to determine the length of the string, then add a “...” on the end of the string and display the full string in a ToolTip. I can't figure out how do get just the displayed portion of the string and append the “...” onto it. Any ideas?

  • Lost in Logan

Dear Lost,

Sometimes the answer is staring you right in the face. The Windows Forms Label control has a AutoEllipsis property that does exactly what you are looking for. Just set it to true and you're done - isn't it nice when you don't have to write code?

  • the Doc

Doc's Doc Tip of the Day

Okay, so it's not exactly documentation, but it's still a tip. Have you checked out the recently redesigned developer portals on MSDN?

Rather than focusing on a specific technology like ASP.NET or language like C#, the portals are aimed at four developer segments: desktop, web, cloud, and phone. For example, the web portal contains not only info on ASP.NET development, but also Silverlight and scripting.

Found a topic in Help that doesn't help? Tell the Visual Studio documentation team about it by clicking on the “Send feedback” link in local Help topics, or the “Click to rate and give feedback” link in online Help.