With over 45,000 topics, finding what you need in the Visual Studio .NET documentation 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,
The .EXE
file from my project has a boring icon in Windows Explorer. How do I assign a custom icon to the .EXE
file? Are there any tools in Visual Studio .NET for making icons? Will the custom icon appear on the Start menu when I deploy my application?
– Ida Knowhow in Idaho
Dear Ida,
Icon help you here! You are only a couple of clicks away from a custom icon for your .EXE
file. The Application icon property is described in the topic “Build, Common Properties, <Projectname>
Property Pages Dialog Box.”
You can use an icon you've created in any paint package. Visual Studio .NET also ships with many icons; you can find those in the Common7\Graphics\icons folder
of your Visual Studio .NET installation. You can also create icons right in Visual Studio .NET, as described in the topic “Creating a New Bitmap or Other Image.”
To make the icon appear on the Start menu, see the topic “Adding and Removing Icons.” Is there anything else icon help you with?
– the Doc
Dear Doc Detective,
I have developed a control that I feel is really commercially viable. However, I cannot seem to find any code / help on how to build the code as either a Web or Windows (I want to do both) control that will sit in the Toolbox and that can be installed with an .EXE
file. Where can I get more help on this?
– Outta Control in Ottawa
Dear Outta,
The Doc is a master in the art of control. First of all, Web and Windows controls are two different things, so you will need a separate project for each. For a Web control, you will want to use a Web Control Library project. Look for the topic “Developing ASP.NET Server Controls” as a good starting point. For the Windows control, you will use a Windows Control Library project, as described in the topic “Walkthrough: Authoring a User Control with Visual Basic .NET.”
Once your control projects are built and thoroughly tested, you will want to create a setup for them. Since your controls will be used with other applications, you should package them in merge modules. The topic “Walkthrough: Creating and Consuming a Merge Module” describes how to do this.
As for installing the controls in the Toolbox, you might want to rethink your strategy?many developers don't appreciate things being added without their permission. If you really want to do this, you can use the Visual Studio .NET automation model to add the controls (and even add your own Toolbox tab) - see “Controlling the Toolbox.” You could then use a custom action in your Setup project to place the controls in the Toolbox during installation - see “Custom Actions” for more information.
Best of luck with your commercial endeavor?hopefully you will soon be controlling a big pile of cash!
– Doc D
Dear Doc Detective,
In an ASP.NET Web page, I'm trying to work with an ActiveX control from server code. I realize that the control is a client-side control, but I want to be able to manipulate it from code-behind. On the page, the object looks like this: <object class-id="xxxx-xxxxx-xxxx-xxx-"></object>
. I've searched everywhere but I can't seem to find any information on doing this. Can you help?
– Conscientious Objecter
Dear Objecter,
The Doctor thought he had an easy answer for you, which was to declare the <object>
tag in HTML view and simply add runat=server and an ID to the <object>
tag, as documented in the topic “Adding HTML Server Controls to a Web Forms Page.” No such luck - if you do, ASP.NET tries to instantiate the object on the server. That might work in some cases, but if your ActiveX control is a client-side control, the GUID for the control probably won't be valid on the server.
So. If you can't declare a control, you can still create it dynamically. Sleuthing about in the documentation, the Doctor first finds the topic “Adding Controls to a Web Forms Page Programmatically,” where he learns that you can create controls on the fly and add them to a container such as a PlaceHolder
control. Easy enough, but what kind of control do you use to instantiate an <object>
element? Here the Doctor needed to read between the lines of the documentation, so to speak. The topic “HTML Server Controls Hierarchy” has a nice illustration of the kinds of HTML elements you can program from server code. None of them match up to an <object>
tag, but a close reading of the topic “HtmlGenericControl” and some experimentation suggest that you can use the HtmlGenericControl
class to instantiate any kind of HTML element on the page.
What about the element attributes? The topic “Setting HTML Server Control Properties Programmatically” shows how to use the Attributes
collection. This is the code that the Doctor came up with to instantiate the Windows Media Player on a Web page:
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim mplayer As New HtmlGenericControl()
mplayer.TagName = "Object"
mplayer.Attributes("classid") = "clsid:22D6F312-B0F6-11D0-94AB-0080C74C7E95"
Dim p1 As New HtmlGenericControl()
p1.TagName = "param"
p1.Attributes("name") = "filename"
p1.Attributes("value") = "C:\MP3\song.mp3"
mplayer.Controls.Add(p1)
PlaceHolder1.Controls.Add(mplayer)
End Sub
Notice that the Doctor could use the HtmlGenericControl
to create both the <object>
elements and the child <param>
elements. Boy, that wasn't obvious, was it? All this research makes the Doc feel like instantiating a Nap
object now.
– The Doc
Doc's Doc Tip of the Day
Did you know that the Help engine supports nested search expressions? Nesting allows you to create more complex search expressions. For example, “control AND ((active OR dde) NEAR window)” finds topics containing the term “control” along with the terms “active” and “window” close together, or containing “control” along with the terms “dde” and “window” close together.