你沒(méi)有寫(xiě)刷新功能嘛,如LblResult.BackColor = Color.LightCoral后面再加一句LblResult.refresh()就實(shí)現(xiàn)了背景色變換!
專(zhuān)注于為中小企業(yè)提供網(wǎng)站建設(shè)、成都網(wǎng)站制作服務(wù),電腦端+手機(jī)端+微信端的三站合一,更高效的管理,為中小企業(yè)翼城免費(fèi)做網(wǎng)站提供優(yōu)質(zhì)的服務(wù)。我們立足成都,凝聚了一批互聯(lián)網(wǎng)行業(yè)人才,有力地推動(dòng)了超過(guò)千家企業(yè)的穩(wěn)健成長(zhǎng),幫助中小企業(yè)通過(guò)網(wǎng)站建設(shè)實(shí)現(xiàn)規(guī)模擴(kuò)充和轉(zhuǎn)變。
VB可使用Point方法來(lái)獲取圖片指定點(diǎn)的顏色。
Point 方法
按照長(zhǎng)整數(shù),返回在 Form 或 PictureBox 上所指定磅的紅-綠-藍(lán) (RGB) 顏色。
語(yǔ)法
object.Point(x, y)
'窗體判色代碼:
Private Sub Form1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
Text1 = X
Text2 = Y
Text3 = Point(X, Y)
Text4 = (Val(Text3) Mod 65536) Mod 256 'Red
Text5 = (Val(Text3) Mod 65536) \ 256 'Green
Text6 = Val(Text3) \ 65536 'Blue
Shape1.FillColor = RGB(Val(Text4), Val(Text5), Val(Text6))
End Sub
'PictureBox判色代碼:
Private Sub Picture1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
Text1 = X
Text2 = Y
Text3 = Picture1.Point(X, Y)
Text4 = (Val(Text3) Mod 65536) Mod 256 'Red
Text5 = (Val(Text3) Mod 65536) \ 256 'Green
Text6 = Val(Text3) \ 65536 'Blue
Shape1.FillColor = RGB(Val(Text4), Val(Text5), Val(Text6))
End Sub
R/G/B值最小是0最大是255屬Byte值類(lèi)型
Dim cr As Color = 控件.BackColor '獲取控件背景色
Dim alpha As Byte = cr.A '透明度
Dim R As Byte = cr.R 'R值
Dim G As Byte = cr.G 'G值
Dim B As Byte = cr.B 'B值
Dim outAcr As Color = Color.FromArgb(alpha, R, G, B) '創(chuàng)建帶有透明通道的ARGB顏色
Dim outcr As Color = Color.FromArgb(R, G, B) '創(chuàng)建不透明的RGB顏色
要使用GetPixel函數(shù)來(lái)取得像素的顏色值,代碼如下:
1
2
3
4
5
private void button1_Click(object sender, EventArgs e)
{
Color color = new Bitmap(pictureBox1.Image).GetPixel(10, 10);
MessageBox.Show(color.ToString());
Label控件是沒(méi)有辦法實(shí)現(xiàn)多種顏色的文字的,只能用RichTextBox來(lái)實(shí)現(xiàn),而且你的自定義格式字符串也沒(méi)有結(jié)尾的,這樣很不好,至少也要red紅色字/redyellow黃色字/yellow,而且實(shí)現(xiàn)也很麻煩的,下面的代碼我沒(méi)有檢測(cè)正確性,有錯(cuò)誤的自己改一改吧
Dim colortag() as string
dim colors() as color
const txt as string="red紅色字/redyellow黃色字/yellow"
private sub Form_Load(object sender,eventargs e)handles mybase.load
colortag(0)="red":Colortag(1)="yellow"
colors(0)=color.red:colors(1)=color.yellow
richtextbox1.text=txt
for i as integer=0 to colortag.lenght-1
dim tag as string="" colortag(i) ""
dim endtag as string="/" colortag(i) ""
dim find as integer=1
do
find=instr(find,txt,tag)+tag.lenght
if(find0)then
dim find1 as integer=instr(find,txt,endtag)
richtextbox1.SelectionStart=find
richtextbox1.selectionlenght=find1-find
richtextbox1.selectioncolor=colors(i)
find=find1
else
exit do
end if
loop
next
end sub
分享名稱(chēng):關(guān)于vb.net輸出色塊的信息
網(wǎng)址分享:http://chinadenli.net/article8/hesjip.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供搜索引擎優(yōu)化、響應(yīng)式網(wǎng)站、外貿(mào)建站、網(wǎng)站建設(shè)、域名注冊(cè)、企業(yè)網(wǎng)站制作
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶(hù)投稿、用戶(hù)轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話(huà):028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來(lái)源: 創(chuàng)新互聯(lián)