无法测试BackColor的控件 [英] Not able to test BackColor of control

查看:69
本文介绍了无法测试BackColor的控件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个Windows窗体,我试图设置一个控件的BackColor

并在我做之前检查颜色:


如果控制.BackColor = System.Drawing.Color.Blue然后

ChangeColor(control,Color.Red)

Else

ChangeColor(control,Color。蓝色)

结束如果


但我收到错误:


运营商''=''不是为类型''System.Drawing.Color''和

定义''System.Drawing.Color''。


我显然可以这样做:


control.BackColor = System.Drawing.Color.Blue


为什么我不能测试颜色?

谢谢,


Tom

I have a Windows form where I am trying to set the BackColor of a control
and check the color before I do it:

If control.BackColor = System.Drawing.Color.Blue Then
ChangeColor(control, Color.Red)
Else
ChangeColor(control, Color.Blue)
End If

But I get an error:

Operator ''='' is not defined for types ''System.Drawing.Color'' and
''System.Drawing.Color''.

I can apparently do:

control.BackColor = System.Drawing.Color.Blue

Why can''t I test the color?

Thanks,

Tom

推荐答案

11月3日,7日:58 pm,tshad < t ... @dslextreme.comwrote:
On Nov 3, 7:58 pm, "tshad" <t...@dslextreme.comwrote:

我有一个Windows窗体,我试图设置一个控件的BackColor

并在我做之前检查颜色:


如果control.BackColor = System.Drawing.Color.Blue那么

ChangeColor(control,Color.Red )

其他

ChangeColor(对照,Color.Blue)

结束如果


但是我得到一个错误:


运算符''=''没有定义类型''System.Drawing.Color''和

''System.Drawing .Color''。


我显然可以这样做:


control.BackColor = System.Drawing.Color.Blue


为什么我不能测试颜色?


谢谢,


Tom
I have a Windows form where I am trying to set the BackColor of a control
and check the color before I do it:

If control.BackColor = System.Drawing.Color.Blue Then
ChangeColor(control, Color.Red)
Else
ChangeColor(control, Color.Blue)
End If

But I get an error:

Operator ''='' is not defined for types ''System.Drawing.Color'' and
''System.Drawing.Color''.

I can apparently do:

control.BackColor = System.Drawing.Color.Blue

Why can''t I test the color?

Thanks,

Tom



尝试使用:


如果是control.BackColor.Equals(System.Drawing.Color.Blue)那么

。 ...

其他

....

结束如果


-

Tom Shelton

Try using:

If control.BackColor.Equals(System.Drawing.Color.Blue ) Then
....
else
....
end if

--
Tom Shelton


" Tom Shelton" < to ********* @ comcast.netwrote in message

news:11 ********************* @ d55g2000hsg.googlegro ups.com ...
"Tom Shelton" <to*********@comcast.netwrote in message
news:11*********************@d55g2000hsg.googlegro ups.com...

11月3日晚上7:58,tshad < t ... @ dslextreme.comwrote:
On Nov 3, 7:58 pm, "tshad" <t...@dslextreme.comwrote:

>我有一个Windows表单,我试图设置一个控件的BackColor
和在我做之前检查颜色:

如果control.BackColor = System.Drawing.Color.Blue那么
ChangeColor(control,Color.Red)
其他
ChangeColor(control,Color.Blue)
结束如果

但是我收到错误:

运算符'''''没有为类型''系统定义.Drawing.Color''和
''System.Drawing.Color''。

我显然可以这样做:

control.BackColor = System.Drawing。 Color.Blue

为什么我不能测试颜色?

谢谢,

Tom
>I have a Windows form where I am trying to set the BackColor of a control
and check the color before I do it:

If control.BackColor = System.Drawing.Color.Blue Then
ChangeColor(control, Color.Red)
Else
ChangeColor(control, Color.Blue)
End If

But I get an error:

Operator ''='' is not defined for types ''System.Drawing.Color'' and
''System.Drawing.Color''.

I can apparently do:

control.BackColor = System.Drawing.Color.Blue

Why can''t I test the color?

Thanks,

Tom



尝试使用:


如果control.BackColor.Equals(System.Drawing.Color.Blue)那么


Try using:

If control.BackColor.Equals(System.Drawing.Color.Blue ) Then



工作正常。


我需要在哪里使用.Equals?


如果我设置一个值,我会假设作业( =),我会

也可以用同样的方式测试它吗?


如果:


control.BackColor = System.Drawing.Color.Blue


为什么不

如果control.BackColor = System.Drawing.Color.Blue那么...


谢谢,


Tom

That worked.

Where else do I need to use .Equals?

I would assume that if I set a value using an assignment (=), that I would
also be able to test it the same way?

If :

control.BackColor = System.Drawing.Color.Blue

why not

IF control.BackColor = System.Drawing.Color.Blue then ...

Thanks,

Tom


...

其他

...

结束如果


-

Tom Shelton
...
else
...
end if

--
Tom Shelton



" tshad" < tf*@dslextreme.comschrieb:
"tshad" <tf*@dslextreme.comschrieb:

>我有一个Windows表单,我试图设置控件的BackColor
并检查我之前的颜色:


如果control.BackColor = System.Drawing.Color.Blue那么

ChangeColor(control,Color.Red)

其他

ChangeColor(控件,Color.Blue)

结束如果


但我收到错误:


运算符''=''没有定义类型''System.Drawing.Color''和

''System.Drawing.Color'' 。
>I have a Windows form where I am trying to set the BackColor of a control
and check the color before I do it:

If control.BackColor = System.Drawing.Color.Blue Then
ChangeColor(control, Color.Red)
Else
ChangeColor(control, Color.Blue)
End If

But I get an error:

Operator ''='' is not defined for types ''System.Drawing.Color'' and
''System.Drawing.Color''.



除了其他回复:我假设你使用的是VB.NET 2002/2003。

那些版本还不支持运算符超载。使用VB 2005,上面的

代码将编译,因为VB 2005支持运算符重载和

''Color''重载''=''(比较)运算符。 br />

-

MS Herfried K. Wagner

MVP< URL:http://dotnet.mvps.org/> ;

VB< URL:http://dotnet.mvps.org/dotnet/faqs/>

In addition to the other replies: I assume you are using VB.NET 2002/2003.
Those versions do not yet support operator overloading. With VB 2005, the
code above would compile because VB 2005 supports operator overloading and
''Color'' overloads the ''='' (comparison) operator.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>


这篇关于无法测试BackColor的控件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆