
正文
vb.net发光文字 vb窗体显示文字
提示:扫一扫查出行【扫一扫了解最新限行尾号】
复制提示
请问VB.NET里面改textbox文字颜色(forecolor)和背景颜色(backcolor)怎么弄?有具体的题目!!
Private Sub CheckBox1_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CheckBox1.CheckedChanged
If CheckBox1.Checked = True Then
TextBox1.ForeColor = Color.Red
Else
TextBox1.ForeColor = Color.Black
End If
End Sub
Private Sub CheckBox2_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CheckBox2.CheckedChanged
If CheckBox2.Checked = True Then
TextBox1.BackColor = Color.Yellow
Else
TextBox1.BackColor = Color.White
End If
End Sub
相关问答
Q1: [VB.NET]如何用VB在窗体中实现闪烁文字
通过使用VB的Timer控件,程序员可以轻松的在窗体上实现闪烁文字的效果。本文将演示如何为Label控件加上闪烁效果,这种方法同样适用于其它多种控件。以下代码可以完成检验ForeColor属性的任务: Private Sub Timer1_Timer() If Label1.ForeColor = Label1.BackColor Then Label1.ForeColor = vbBlack Else Label1.ForeColor = Label1.BackColor End If End Sub 另外,你也可以让文字采用不同的颜色,比如交替采用红色和绿色: Private Sub Timer1_Timer() If Label1.ForeColor = vbRed Then Label1.ForeColor = vbGreen Else Label1.ForeColor = vbRed End If End Sub 当你停止文字闪烁时,还要确定文字的状态是可见的并且采用了合适的色彩。
Q2: VB.NET如何显示多种颜色的一段文本?
Label控件是没有办法实现多种颜色的文字的,只能用RichTextBox来实现,而且你的自定义格式字符串也没有结尾的,这样很不好,至少也要red红色字/redyellow黄色字/yellow,而且实现也很麻烦的,下面的代码我没有检测正确性,有错误的自己改一改吧
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
Q3: vb.net 字体如何设置?(font,fontfamily)
可以利用font 设置。设置方法如下vb.net发光文字:
TextBox1.Font = New System.Drawing.Font("宋体", 10)
也可以通过字体对话框来实现 如vb.net发光文字:
Private Sub myButton_Click(sender As Object, e As EventArgs)
Dim myFontDialog As FontDialog
myFontDialog = New FontDialog()
If myFontDialog.ShowDialog() = DialogResult.OK Then
' Set the control's font.
myDateTimePicker.Font = myFontDialog.Font
End If
End Sub
Q4: vb.net 高亮度显示文本
选中就是高亮vb.net发光文字,首先得到你找到的文本字符的起始位置和长度vb.net发光文字,然后
TextBox.Select(start,length)
或
TextBox.SelectionStart = start
TextBox.SelectionLength = length
vb.net发光文字的介绍就聊到这里吧,感谢你花时间阅读本站内容,更多关于vb窗体显示文字、vb.net发光文字的信息别忘了在本站进行查找喔。







