Sharing bitmaps
Hi All,
I asked a similar question in a different forum but got no response, maybe it was the wrong place.
Basically I wanted to know if it was possible 'share' a bitmap on two forms? If I wanted the same image on two forms the designer always wants to embed the bitmap in to rach form resource. If I change the bitmap then I have to go through all forms that use it and update them.
I know this sort of thing is possible in code, using a resource manager but I also wanted to get designer support. Am I expecting too much?
Please help.
Thanks.
Graham
If you just add the bitmaps as an embedded resource you can assign it programatically to whatever you want. I do a similar thing with toolbars, I have all the toolbar images as embedded resource files (added them to the project, set "Build Action" to embedded resource). This adds the print button image to a print button called tbbPrint. This code goes in the constructor of my form after the InitializeComponent() call:
Dim a As Reflection.Assembly
a = a.GetExecutingAssembly()
If components Is Nothing Then
components = New System.ComponentModel.Container()
End If
Dim il As New ImageList(components)
Me.tb.ImageList = il
tbbPrint.ImageIndex = il.Images.Add(New Bitmap(a.GetManifestResourceStream("PRINT.BMP")), Color.Silver)