本文介绍了在.NET中将字符串转换为System.Color的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

美好的一天,我试图在VB.NET上制作此应用程序,以便用户可以更改应用程序的背景色,当应用程序关闭时,该颜色应保存为XML.节省是小菜一碟,但是现在真正的难题是如何将字符串"Color [white]" 转换为 System.Color .

Good day, I'm trying to make this application on VB.NET in which the user can change the background color of the application, when the application closes the color should save to a XML. The saving was piece of cake but now the real dilemma is how to convert the String "Color[white]" to a System.Color.

我已经用Google搜索了问题,但没有结果.另外, Color.FromName 我已经很熟悉了.

I already Googled my problem but no result. Plus I'm already familiar to Color.FromName.

非常感谢.

推荐答案

Dim C = System.Drawing.Color.FromName(YourColorString.Replace("Color[" , "").Replace("]", ""))

这篇关于在.NET中将字符串转换为System.Color的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-28 17:26