ukjock Posted July 28, 2004 Posted July 28, 2004 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 Quote ----------------- It�s always funny until someone gets hurt� Then it become hilarious!
bpayne111 Posted July 29, 2004 Posted July 29, 2004 try using ctype to convert the icon to an image when you set the property. i hope that helps some brandon Quote i'm not lazy i'm just resting before i get tired.
*Experts* DiverDan Posted July 29, 2004 *Experts* Posted July 29, 2004 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 Quote Member, in good standing, of the elite fraternity of mentally challenged programmers. Dolphins Software
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.