新聞中心
VB.NET文本框顏色變不了,為什么最后LBLNo1的背景色始終是綠色和紅色 點擊它的第一時間不應該是白色嗎?
你沒有寫刷新功能嘛,如LblResult.BackColor = Color.LightCoral后面再加一句LblResult.refresh()就實現(xiàn)了背景色變換!
專注于為中小企業(yè)提供網(wǎng)站建設、成都網(wǎng)站制作服務,電腦端+手機端+微信端的三站合一,更高效的管理,為中小企業(yè)翼城免費做網(wǎng)站提供優(yōu)質(zhì)的服務。我們立足成都,凝聚了一批互聯(lián)網(wǎng)行業(yè)人才,有力地推動了超過千家企業(yè)的穩(wěn)健成長,幫助中小企業(yè)通過網(wǎng)站建設實現(xiàn)規(guī)模擴充和轉(zhuǎn)變。
vb.net拾色器設計,要求:能獲取圖片任意位置的顏色
VB可使用Point方法來獲取圖片指定點的顏色。
Point 方法
按照長整數(shù),返回在 Form 或 PictureBox 上所指定磅的紅-綠-藍 (RGB) 顏色。
語法
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
VBNET怎么獲取控件顏色的RGB值,又怎么用RGB將顏色賦給控件顏色。
R/G/B值最小是0最大是255屬Byte值類型
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顏色
在vb.net中,如何獲取Graphics中某一指定點(像素)的顏色值?(VB語言)
要使用GetPixel函數(shù)來取得像素的顏色值,代碼如下:
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());
VB.NET如何顯示多種顏色的一段文本?
Label控件是沒有辦法實現(xiàn)多種顏色的文字的,只能用RichTextBox來實現(xiàn),而且你的自定義格式字符串也沒有結(jié)尾的,這樣很不好,至少也要red紅色字/redyellow黃色字/yellow,而且實現(xiàn)也很麻煩的,下面的代碼我沒有檢測正確性,有錯誤的自己改一改吧
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
當前標題:關(guān)于vb.net輸出色塊的信息
分享網(wǎng)址:http://fisionsoft.com.cn/article/hesjip.html