HighTechTalks DotNet Forums  

Converting Text to Default Colors in VB.NET

Dotnet Framework (Drawing) microsoft.public.dotnet.framework.drawing


Discuss Converting Text to Default Colors in VB.NET in the Dotnet Framework (Drawing) forum.



Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old   
Terry
 
Posts: n/a

Default Converting Text to Default Colors in VB.NET - 09-30-2004 , 02:35 PM






I have an XML file that has settings for my app. Many of the settings
involve color (i.e. <BackColor>Red</BackColor>). The XML value is read into
a string, so I have a string called strBackColor with the value "Red". Now I
want to set the form to BackColor.Red. How do I do this without having a
giant SELECT like this...

SELECT CASE strBackColor
CASE "Red"
Me.BackColor = Backcolor.Red
CASE "Blue"
Me.BackColor = Backcolor.Red
....
END SELECT

Acually, I want it to be part of a global shared method that I can use
throughout my system, where I pass in a String and it returns the color..like

Me.BackColor = CStringToColor(strBackColor)

Thanks for your help,
Terry

Reply With Quote
  #2  
Old   
James Westgate
 
Posts: n/a

Default Re: Converting Text to Default Colors in VB.NET - 10-01-2004 , 08:44 AM






Terry,

Try the color.FromName static method. Obviously your xml colro scheme will
have to match the scheme defined but its pretty comprehensive

James

--
Create interactive diagrams and flowcharts with ERM Diagram at
http://www.crainiate.net

Take the ERM Tour at http://www.flowchartcontrol.com

"Terry" <Terry (AT) discussions (DOT) microsoft.com> wrote

Quote:
I have an XML file that has settings for my app. Many of the settings
involve color (i.e. <BackColor>Red</BackColor>). The XML value is read
into
a string, so I have a string called strBackColor with the value "Red".
Now I
want to set the form to BackColor.Red. How do I do this without having a
giant SELECT like this...

SELECT CASE strBackColor
CASE "Red"
Me.BackColor = Backcolor.Red
CASE "Blue"
Me.BackColor = Backcolor.Red
...
END SELECT

Acually, I want it to be part of a global shared method that I can use
throughout my system, where I pass in a String and it returns the
color..like

Me.BackColor = CStringToColor(strBackColor)

Thanks for your help,
Terry



Reply With Quote
Reply




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.