Ask the Doc Detective
Finding what you need in the Microsoft® Visual Studio® 2005 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 email@example.com.
Dear Doc Detective,
I wonder if you can help. The Visual Studio documentation mentions that output of an XML documentation file can be enabled on the project property pages by setting the XML Documentation File property. However, for an ASP.NET Web site, there is no such property available on the property pages. Where/how can I set this property for an ASP.NET Web site (file or Web-based) in Visual Studio 2005?
- Missing in Mississauga
The Visual Studio documentation does indeed state that, but in this case it appears to be wrong. The XML Documentation File property only applies to Windows applications, class libraries, and console apps.
There is, however, a trick you might try. Assuming that your code is in a .cs file, you should be able to generate the XML documentation file by compiling the file via the command line compiler using the /doc compiler option. The compiler isn’t smart enough to know that your code file came from a Web project, or maybe it just doesn’t care.
- Doc D
Dear Doc Detective,
I am creating a custom user control. Initially, the UserControl has its default properties, methods, etc. I would like to remove some properties that are not needed for my control, and add some that are needed.
I have been able to successfully add some properties, but the added properties always show up on the property page under the "Misc" category. I would like them to show up under the "Layout" category.
So, my question is: How do I add properties to a specific category of the properties, and how do I remove unneeded properties and methods?
--Disorganized in Douglasville
If I’m counting correctly, that would be two questions-and they are both good ones. I’ve always wondered how this was done, so I rolled up my sleeves and dug into the docs.
It turns out that there are a couple of attributes that you can apply to your properties-Browsable determines whether a property will be shown in the Properties window, and Category determines where they are placed-you can even create your own section. There is an example of this in the topic "Walkthrough: Creating a Windows Forms Control That Takes Advantage of Visual Studio Design-Time Features". Look in the “To create a child control for your custom control” section, step 11.
As for hiding properties, it depends on where they are coming from. If you are creating a composite control, you decide which properties of the constituent controls you want to expose. To learn more, see "How to: Expose Properties of Constituent Controls".
If you are inheriting from UserControl and the properties that you want to hide are Overridable, you should be able to override them in your class and use the Browsable attribute to hide them. Another alternative would be to wrap your control in another User Control, essentially making it a composite control, and then exposing only the properties that you want.
- Doctor D
Dear Doc Detective,
I want to use the same icon for my application (the one that shows up in the Start menu) and for each of the forms in my app (the ones that show up in the Taskbar). I added the icon to my project in the Project designer, but when I try to add it to the form via the SystemIcons.Application property the forms show a different icon.
Surely there must be a way to reuse my application icon in my forms. Where did I go wrong?
- Wondering in Waycross
You probably went wrong by not carefully reading the reference documentation. The topic for the SystemIcons.Application property states that it returns "An Icon object that contains the default application icon." Note the word "default" -what you are seeing is the default Application Icon that Visual Studio uses if you don’t specify your own.
There is no way to directly set a form’s Icon property to the Application Icon that you set in the Project Designer. You can, however, use a single icon for both your application and your forms by adding the icon as a resource, as described in the topic "How to: Add or Remove Resources".
Once you’ve added it, in the Project Designer choose your icon from the drop-down list for "Application Icon". To set the form icon for each form you would add the following code in each form’s Form_Load event:
Me.Icon = My.Resources.myReallyCoolIcon
The lesson learned here is: it pays to be resourceful!
- the Doc
Doc’s Doc Tip of the Day
Ever notice that sometimes when you press F1 in the Code Editor you get the wrong result? A reader reported a discrepancy when trying to get help on File.Open-placing the cursor on the word Open and pressing F1 brought up the right topic, but highlighting Open and pressing F1 brought up a SQLConnection.Open topic.
While this behavior may seem odd, it’s actually by design. The F1 logic looks at the current position of the cursor, then uses that word and any surrounding words to establish context, then it does the F1 lookup.
If you highlight the word, it doesn’t look for context-it just finds the first instance of that keyword and displays the topic. In this case, the SQLConnection.Open topic has a higher priority than the File.Open topic, so it was found first.
If you highlight both File and Open, it “might” have enough context to find the right topic, but if there is more than one File.Open topic you may still get the wrong one. Bottom line: Don’t highlight the keyword and you’ll be fine.
Found a topic in Help that doesn’t help? Tell the Visual Studio documentation team about it at firstname.lastname@example.org.