Re: I'm in over my head on this one. Clarification please...
Hi David,
I recommend that you do not use your UI elements as state variables
(don't use your GUI controls to be the difinitive holder of important
imformation). Instead, you need to be keeping up with state in actual
variables or objects. Create a class or a struct that contains your
stuff, or just make them properties on your form (like a bool property
named IsConnected). In the set method of the property, you'd set the
appropriate icon on your status bar.
You need to keep track of your data in appropriately typed and named
variables or properties and your UI should be considered a
"reflection" of your state, not "definition" of your state. If you
need to examine something, you should be looking at your variables.
Your GUI elements should be changed as a side effect of setting your
actual variables and you should never look into your GUI elements to
determine what's going on, except of course, for user input controls
like text boxes and such, but then, after you collect the information
from even those types of controls, they should be stored and used in
proper variables (not the GUI elements).
Try that shift in your thought process and I'll bet things work out a
lot better for you.
--------------------------
Owner/Operator of
www.MichaelsAttic.com
On Feb 11, 1:33 pm, "David Schrader" wrote:
> Hello all,
>
> First time in this specific NG but long time reader and applicant to
> other NGs. I'm just beginning with VS2008 - a great took incidentally
> - but I've run into something I've been unable to fathom. Will some-
> one be kind enough to filter out some of the sediment so I can get
> clear what I need to do?
>
> I have a program which will have an *icon* in the *status bar.* When
> the application is connected to the internet I want to show one icon
> but when it is disconnected I want to display a second icon.
>
> I want to "test" to see what icon is (currently) being displayed and
> toggle icons provided the condition is true or not. My code, at this
> time looks like:
>
> If ssActivityIcon.Image = Appl.My.Resources.Resource.<IconY> Then> ssActivityIcon.Image = Appl.My.Resources.Resource.<IconN>
> ElseIf _
> ssActivityIcon.Image = Appl.My.Resources.Resource.<IconN> Then
> ' Do nothing
> Else _
> ssActivityIcon.Image = Appl.My.Resources.Resource.<IconY>
> End If
> :
> : Do some things here... then:
> :
> If ssActivityIcon.Image = Appl.My.Resources.Resource.<IconN> Then> ssActivityIcon.Image = Appl.My.Resources.Resource.<IconY>
> ElseIf _
> ssActivityIcon.Image = Appl.My.Resources.Resource.<IconY> Then
> ' Do nothing
> Else _
> ssActivityIcon.Image = Appl.My.Resources.Resource.<IconN>
> End If
>
> I get the error message "Operator "=" is not defined for types
> "System.Drawing.Image" and "System.Drawing.Bitmap."
>
> I'm relatively certain that the error relates to the "IF" structure
> and not the assignment(s) but I'm not certain what operation I need
> to use to (or how to go about) compare comparing the names of two
> different icons. I know that there's a way to do it but...
>
> Suggestions?
>
> David
date: Mon, 11 Feb 2008 20:26:01 -0800 (PST)
author: Mike {0A6FF490-CF84-4d78-BD85-FF011A0C310C}