资讯

精准传达 • 有效沟通

从品牌网站建设到网络营销策划,从策略到执行的一站式服务

vb.net定义的颜色 vb颜色函数

vb.net 如何读取ini文件定义的ForeColor颜色值

你好,我不知道你是用什么方法保存的,不过.net里的color有一个方法是Color.FromArgb 你可以这么做,dim

创新互联公司专注于雨湖企业网站建设,成都响应式网站建设公司,商城开发。雨湖网站建设公司,为雨湖等地区提供建站服务。全流程定制网站,专业设计,全程项目跟踪,创新互联公司专业和态度为您提供的服务

c

as

color=richtextbox1.ForeColor dim

colorstring

as

string=c.ToArgb().ToString

colorstring就是颜色的值(字符串)再把colorstring保存到ini文件加载颜色的时候,从ini里读取colorstring 具体是:dim

RtextColor

as

color=Color.FromArgb(cint(colorstring))richtextbox1.ForeColor

=RtextColor

vb编程,自定义变量实现颜色?请指教下

其实这个问题特简单,但是三色需要三个文本框(数组控件)分别输入,设置红色、绿色、蓝色,在文本框的Text1_Change事件中设置Text2的颜色就可以了。

Private Sub Form_Load()

Text2.Text = "你好吗?"

Text2.FontSize = 20

Text2.FontBold = True

End Sub

Private Sub Text1_Change(Index As Integer)

Dim AA As Integer, BB As String

AA = Index

If AA = 0 Then BB = "红色"

If AA = 1 Then BB = "绿色"

If AA = 2 Then BB = "蓝色"

If IsNumeric(Text1(AA).Text) = False Then

MsgBox "你输入的"  BB  "不是数字,各种颜色的值必须是0-255之间的正整数!"

Text1(AA).Text = ""

Text1(AA).SetFocus

Exit Sub

End If

If Val(Text1(AA).Text)  0 Or Val(Text1(AA).Text)  255 Then

MsgBox "你输入的"  BB  "数字不正确,不能小于0,也不能大于255!"

Text1(AA).Text = ""

Text1(AA).SetFocus

Exit Sub

End If

If Val(Text1(0).Text) = 0 And Val(Text1(0).Text) = 255 And Val(Text1(1).Text) = 0 And Val(Text1(1).Text) = 255 And Val(Text1(2).Text) = 0 And Val(Text1(2).Text) = 255 Then

Text2.ForeColor = RGB(Val(Text1(0).Text), Val(Text1(1).Text), Val(Text1(2).Text))

End If

End Sub

c#/vb.net如何通过反射获得颜色名称(字符串)对应的颜色(Color类型)?

public Color col(string colorName)

{

Type colorType = typeof(Color);

PropertyInfo info = colorType.GetProperty(colorName, BindingFlags.Public | BindingFlags.Static);

if (infos == null)

{

//throw Exception

}

return(Color)info.GetValue(null, null);

}

是这个意思么?输入“Red”, 返回Color.Red 区分大小写

vb.net 中如何修改toolstripButton 选中时的颜色

如果你要的是选中变色,那用checked属性就可以了。

如果你要自定义选中变的颜色,就需要过程了。

代码可以放在checkedchange事件中,通过改变displaystyle,image或者backcolor实现


分享文章:vb.net定义的颜色 vb颜色函数
标题URL:http://cdkjz.cn/article/dohjdcc.html
多年建站经验

多一份参考,总有益处

联系快上网,免费获得专属《策划方案》及报价

咨询相关问题或预约面谈,可以通过以下方式与我们联系

业务热线:400-028-6601 / 大客户专线   成都:13518219792   座机:028-86922220