E
eBob.com
Context: I'd like to add a column to an unbounded DataGridView for an icon.
Different icons will be used in different rows.
I found this code in researching how to do this ...
Dim PlusIcon As New Icon(Me.GetType(), "Plus.ico")
Dim iconColumn As New DataGridViewImageColumn()
With iconColumn
.Image = PlusIcon.ToBitmap()
.Name = "Plus"
.HeaderText = "Header Text"
End With
MasterDGV.Columns.Insert(2, iconColumn)
(I found the code here:
http://msdn.microsoft.com/en-us/library/2ab8kd75.aspx; the code above
changes the name of the icon and DataGridView.)
Documentation for the example says that I will need an "embedded icon
resource" named Plus.ico. I couldn't find anything explicit about how to
add an embedded icon resource to my project, but I stumbled around and ended
up using Project > Add Existing Item (VS2008). I can't be certain that
worked but at least Solution Explorer now knows about the icon files I
added.
In any event, when I try to execute the code above I get "Argument Exception
was unhandled / Resource 'Plus.ico' cannot be found in class ...".
Actually I did find instruction
(http://www.devx.com/dotnet/Article/10831/1954) titled "How to Embed
Resource Files in .NET Assemblies" but it refers to a "Build Action"
Property which I cannot find. In fact, on my VS View menu "Property Pages"
is greyed out.
I'd sure appreciate any help anyone can offer.
Thanks, Bob
Different icons will be used in different rows.
I found this code in researching how to do this ...
Dim PlusIcon As New Icon(Me.GetType(), "Plus.ico")
Dim iconColumn As New DataGridViewImageColumn()
With iconColumn
.Image = PlusIcon.ToBitmap()
.Name = "Plus"
.HeaderText = "Header Text"
End With
MasterDGV.Columns.Insert(2, iconColumn)
(I found the code here:
http://msdn.microsoft.com/en-us/library/2ab8kd75.aspx; the code above
changes the name of the icon and DataGridView.)
Documentation for the example says that I will need an "embedded icon
resource" named Plus.ico. I couldn't find anything explicit about how to
add an embedded icon resource to my project, but I stumbled around and ended
up using Project > Add Existing Item (VS2008). I can't be certain that
worked but at least Solution Explorer now knows about the icon files I
added.
In any event, when I try to execute the code above I get "Argument Exception
was unhandled / Resource 'Plus.ico' cannot be found in class ...".
Actually I did find instruction
(http://www.devx.com/dotnet/Article/10831/1954) titled "How to Embed
Resource Files in .NET Assemblies" but it refers to a "Build Action"
Property which I cannot find. In fact, on my VS View menu "Property Pages"
is greyed out.
I'd sure appreciate any help anyone can offer.
Thanks, Bob