Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

I have put some icons in to my statuspanel of my statusbar.

 

I want to call them though from an imagelist but I am not having much success I am trying the following code:

 

If StatusBar1.Panels(2).Text >= "12:00:00" Then StatusBar1.Panels(2).Icon = time.Images.Item(0)

 

But I get the error can not convert system.drawing.image can not be converted system.drawing.icon.

 

Any ideas on how I can get around this.

 

Any help appreciated

 

Regards

 

Chris

-----------------

It�s always funny until someone gets hurt� Then it become hilarious!

  • *Experts*
Posted

I think the status bar only accepts icons, and dotnet views icons in an imagelist as...images not icons.

 

You can add the icons to your program as an embedded resource then load and access them in an array fairly easily.

 

Use "Add Existing Item" from the Project menu selection and change the icons build Action to Embedded Resource.

 

Globally declare statusIcons(1) as Icon

Then add Load_statusIcons() to your form's load event

 

   Private Sub Load_statusIcons()
       Dim CurrentAssembly As String = Reflection.Assembly.GetExecutingAssembly().GetName().Name.ToString
       Dim iconFile As IO.Stream
       Dim iconFileName() As String = {"icon1.ico", "icon2.ico"} 'etc.

       For i = 0 To statusIcons.GetUpperBound(0)
           iconFile = Reflection.Assembly.GetExecutingAssembly().GetManifestResourceStream(CurrentAssembly + "." + iconFileName(i))
           statusIcons(i) = New Icon(iconFile)
       Next
   End Sub

 

statuspanel.Icon = statusIcons(0)

 

Hope that helps

Dan

Member, in good standing, of the elite fraternity of mentally challenged programmers.

 

Dolphins Software

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...