[分享]字符串(颜色名称/十六进制) 转Color类型 Post By:2024/10/6 16:11:00 [显示全部帖子]
' 2024-10-6 将字符串(颜色名称/十六进制) 转Color类型
Dim colorName As String = Args(0) ' "#32CD32" , "red"
' 创建 ColorConverter
Dim converter As System.ComponentModel.TypeConverter = System.ComponentModel.TypeDescriptor.GetConverter(GetType(Color))
' 将颜色名称转换为 Color 对象
Dim clr As Color = CType(converter.ConvertFromString(colorName), Color)
Return clr