Finding what you need in the Microsoft® Visual Studio® .NET documentation, which has over 45,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 docdetec@microsoft.com.
Dear Doc Detective,
I need to install Internet Explorer along with an application that I wrote in Visual Basic using Visual Studio .Net 2003. I would like to write some generic code which could install any application. Is there a way to do this?
- Curious in Cucamonga
Dear Curious,
Indeed there is-you can install Internet Explorer via a custom action that runs at the end of your installation created using a Setup project. Take a look at the custom action walkthrough, "Walkthrough: Creating a Custom Action," for an example.
Instead of launching a URL as in the example, you would launch the Setup.exe for Internet Explorer, which you would need to include as a file packaged with your application.
Since most users probably already have Internet Explorer installed, you would also want to define a launch condition to check for it and run the custom action only if it isn't found. The deployment walkthrough, "Walkthrough: Deploying a Windows Application," contains an example of this in the section, "Adding Launch Conditions."
- Doc D
Dear Doc Detective,
I have 199 fonts in my office environment, and really need a way to tell which ones are fixed-pitch for RichTextBox output-Courier New is just too bland.
It seems that none of the Font classes have a method for fixed-pitch fonts. I thought it might be IsFixedSized, but that's set to True for the first 10 I saw while debugging the program, and I know they weren't fixed-pitched.
- Fontless in Fontana
Dear Fontless,
You are correct-the Font object doesn't have a property or method to tell you if a font uses proportional or monospace (fixed-pitch) spacing. There is, however, a way to get a list of fixed-pitch fonts on your system using a FontDialog component.
The FontDialog class has a FixedPitchOnly property that forces the dialog to list only fixed-pitch fonts. See the topic, "FontDialog.FixedPitchOnly Property" for more information. That should "fix" your problem.
- Doctor D
Dear Doc Detective,
Back when I was using VB 6, I used the PopupMenu method to "steal" a top level menu and display its sub-items as a context menu. Now that I'm using VB .NET I would like to do the same thing, but I can't find an equivalent for the PopupMenu method.
Is there a way to reuse a MainMenu as a ContextMenu, or do I have to create a separate ContextMenu with the same commands?
-- Menuless in Menlo Park
Dear Menuless,
There is indeed a way to do this in .NET, but it's not quite as simple as it was in VB 6. Although you can't share a menu item between a MainMenu and a ContextMenu, you can use the Clone method of the MenuItem to create a copy on the fly.
A common scenario for this would be to clone the Cut / Copy / Paste commands from an Edit menu and reuse them as a context menu for a group of edit controls. The topic, "Copying Items on Windows Forms Menus" in the MSDN Library describes how to do just that.
- the Doc
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 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?
-- Obscured in Oxnard
Dear Obscured,
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 parents background inside the bounds of the label.
Fortunately there are a couple of ways to work around this. 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, "Drawing Text with GDI+".
The other solution is to remove the PictureBox control and draw its contents in the Paint event. The topic, "Rendering Images with GDI+" explains how to draw an image on a form.
Either solution will allow your floating label to have the correct transparent behavior.
-- Doc Detective
Doc's Doc Tip(s) of the Day
In Visual Studio .NET, when you press F1 to get Help, the Help topic shows up in the IDE in a docked window. To make it easier to read Help while working, you can undock the window in various ways. One is to right-click the tab for the Help topic and then choose Floating.
You might also find it useful to open Help as a separate application. From the Start menu, choose All Programs, Microsoft Visual Studio .Net 2003, Microsoft Visual Studio .Net 2003 Documentation. (Make yourself a shortcut if you do this often.) That way, you can use ALT+TAB to switch between the IDE and Help.
Found a topic in Help that doesn't help? Tell the Visual Studio documentation team about it at vsdocs@microsoft.com.
URLs