vb.net 设置不同的文本时是否可以更改文本颜色?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/20584458/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Is it possible to change text colour when different text is set?
提问by LukeSC1993
I know the title doesn't describe too good but I was wondering if there was a certain code to type into Visual Basic to make the text in a textbox change colour when the text changes.
我知道标题描述得不太好,但我想知道是否有特定的代码可以输入到 Visual Basic 中,以便在文本更改时使文本框中的文本更改颜色。
Here is my code:
这是我的代码:
If My.Computer.Network.IsAvailable Then
txtnetwork.Text = "Connected"
Else
txtnetwork.Text = "Disconnected"
End If
So is there a way of making the "Connected" text Green, and the "Disconnected" text Red?
那么有没有办法将“已连接”文本设为绿色,将“已断开连接”文本设为红色?

