By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
429,045 Members | 1,305 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 429,045 IT Pros & Developers. It's quick & easy.

Controls - background colour

P: n/a
Al
I hope I'm in the right group for this question.

I'm new to VB.net and am trying to change the background color of a button
when it is "clicked."

I'm using the code

"ctl..BackColor = System.Drawing.Color.Teal"

in the form_load event and it works, however when using the code with a
different color in the ctl_click event of the relevent button, in putting it
in an "If - then" statement, I'm being told that The operator'=' is not
defined.

I've some experience of VBA, however canot work this one out and would be
grateful for any assistance

Thanks

@l@n
Nov 22 '05 #1
Share this Question
Share on Google+
4 Replies


P: n/a
I take it your doing

If ctl.BackColor = Color.Teal Then........

Color does not support the = operator.. check out Color.Op_Equality.. I
think..

not sure if this is the best or most efficient.. but it works..

HTH

"Al@n" <no*@thisdomain.co.uk> wrote in message
news:#U**************@TK2MSFTNGP10.phx.gbl...
I hope I'm in the right group for this question.

I'm new to VB.net and am trying to change the background color of a button
when it is "clicked."

I'm using the code

"ctl..BackColor = System.Drawing.Color.Teal"

in the form_load event and it works, however when using the code with a
different color in the ctl_click event of the relevent button, in putting it in an "If - then" statement, I'm being told that The operator'=' is not
defined.

I've some experience of VBA, however canot work this one out and would be
grateful for any assistance

Thanks

@l@n

Nov 22 '05 #2

P: n/a
Al
HTH

Thanks for your assistance. I think I'm on the right track
now. If you have a more efficient way of doing this, I'd
be graeful for any input.

Al@n
-----Original Message-----
I take it your doing

If ctl.BackColor = Color.Teal Then........

Color does not support the = operator.. check out Color.Op_Equality.. Ithink..

not sure if this is the best or most efficient.. but it works..
HTH

"Al@n" <no*@thisdomain.co.uk> wrote in message
news:#U**************@TK2MSFTNGP10.phx.gbl...
I hope I'm in the right group for this question.

I'm new to VB.net and am trying to change the background color of a button when it is "clicked."

I'm using the code

"ctl..BackColor = System.Drawing.Color.Teal"

in the form_load event and it works, however when using the code with a different color in the ctl_click event of the relevent button, in putting
it
in an "If - then" statement, I'm being told that The

operator'=' is not defined.

I've some experience of VBA, however canot work this one out and would be grateful for any assistance

Thanks

@l@n

.

Nov 22 '05 #3

P: n/a
ur welcome..

I'm not saying this IS inefficient.. just not sure if there's a more
efficient way of doing it. if there is I haven't come across it yet.

I'm fairly new to .NET myself.. so if anyone else has any input???

HTH - Hope This Helps.. not my name..

Rigga. (This is my name.. ) ;-)

"Al@n" <an*******@discussions.microsoft.com> wrote in message
news:31****************************@phx.gbl...
HTH

Thanks for your assistance. I think I'm on the right track
now. If you have a more efficient way of doing this, I'd
be graeful for any input.

Al@n
-----Original Message-----
I take it your doing

If ctl.BackColor = Color.Teal Then........

Color does not support the = operator.. check out

Color.Op_Equality.. I
think..

not sure if this is the best or most efficient.. but it

works..

HTH

"Al@n" <no*@thisdomain.co.uk> wrote in message
news:#U**************@TK2MSFTNGP10.phx.gbl...
I hope I'm in the right group for this question.

I'm new to VB.net and am trying to change the background color of a button when it is "clicked."

I'm using the code

"ctl..BackColor = System.Drawing.Color.Teal"

in the form_load event and it works, however when using the code with a different color in the ctl_click event of the relevent button, in putting
it
in an "If - then" statement, I'm being told that The

operator'=' is not defined.

I've some experience of VBA, however canot work this one out and would be grateful for any assistance

Thanks

@l@n

.

Nov 22 '05 #4

P: n/a
The other way is to use Equals.

Color1.Equals(Color2)
"Rigga" <s@g.c> wrote in message
news:IH*********************@stones.force9.net...
ur welcome..

I'm not saying this IS inefficient.. just not sure if there's a more
efficient way of doing it. if there is I haven't come across it yet.

I'm fairly new to .NET myself.. so if anyone else has any input???

HTH - Hope This Helps.. not my name..

Rigga. (This is my name.. ) ;-)

"Al@n" <an*******@discussions.microsoft.com> wrote in message
news:31****************************@phx.gbl...
HTH

Thanks for your assistance. I think I'm on the right track
now. If you have a more efficient way of doing this, I'd
be graeful for any input.

Al@n
-----Original Message-----
I take it your doing

If ctl.BackColor = Color.Teal Then........

Color does not support the = operator.. check out

Color.Op_Equality.. I
think..

not sure if this is the best or most efficient.. but it

works..

HTH

"Al@n" <no*@thisdomain.co.uk> wrote in message
news:#U**************@TK2MSFTNGP10.phx.gbl...
> I hope I'm in the right group for this question.
>
> I'm new to VB.net and am trying to change the

background color of a button
> when it is "clicked."
>
> I'm using the code
>
> "ctl..BackColor = System.Drawing.Color.Teal"
>
> in the form_load event and it works, however when using

the code with a
> different color in the ctl_click event of the relevent

button, in putting
it
> in an "If - then" statement, I'm being told that The

operator'=' is not
> defined.
>
> I've some experience of VBA, however canot work this

one out and would be
> grateful for any assistance
>
> Thanks
>
> @l@n
>
>
.


Nov 22 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.