Using the System.Drawing.ToolboxBitmap attribute in VB.NET

Giganews Newsgroups
Subject: Using the System.Drawing.ToolboxBitmap attribute in VB.NET
Posted by:  Nathan Sokalski (njsokals…@hotmail.com)
Date: Sun, 2 Nov 2008

I am attempting to create icons for controls I have created using VB.NET by
using the System.Drawing.ToolboxBitmap attribute. I have managed to do this
in C# by specifying the path to the *.ico file, but I have been unable to
get any of the overloads to work in VB.NET. I would like to store the *.ico
files in a *.resx file so that users do not need anything other than the
*.dll, but at the moment I am just trying to get any of the overloads of
System.Drawing.ToolboxBitmap to work in VB.NET. Here is my code and
directories (obviously not all files are listed, but I think these are the
ones of significance):

NateCtrl2005 (this is the name of my project)
    My Project
        Resources.resx (this is the resources file with my *.ico files)
    ToolboxIcons (folder where I am storing the *.ico files)
        ConditionalRequiredTextValidator.ico (Build Action=Embedded
Resource)
    ConditionalRequiredTextValidator.vb

Code in ConditionalRequiredTextValidator.vb:

Namespace NathanSokalski
    <System.Drawing.ToolboxBitmap("C:\Inetpub\wwwroot\NateCtrl2005\ToolboxIcons\ConditionalRequiredTextValidator.ico")>
Public Class ConditionalRequiredTextValidator
        .
    End Class
End Namespace

I have tried all three overloads of System.Drawing.ToolboxBitmap, and could
not get any of them to work. I have heard stuff about them not all working
correctly in VB.NET, but even in C# I was only able to get the one where the
path of the *.ico is specified to work. I think that Visual Studio should
have some kind of attribute editor or something (it lets you use the
Property Grid to set the Category and Default Value for properties, and
several things for the class, but not this one or many of the others). If
someone could help me I would appreciate it. Thanks.

--
Nathan Sokalski
njsokals…@hotmail.com
http://www.nathansokalski.com/

Replies