Hi,
Can I use a string variable to set a color property of a control? e.g.
strCol="Color.Red"
Textbox1.BackColor=strcol (which of course does not work)
Printable View
Hi,
Can I use a string variable to set a color property of a control? e.g.
strCol="Color.Red"
Textbox1.BackColor=strcol (which of course does not work)
VB Code:
Dim c As Color = CType(TypeDescriptor.GetConverter(GetType(Color)).ConvertFromString("Red"), _ Color) Me.BackColor = c
:afrog:
in addition to master crptcblade
VB Code:
Dim s As String = "Brown" 'Monkey Me.BackColor = Color.FromName(s)
Didn't even notice that method. Even better.Quote:
Originally posted by brown monkey
in addition to master crptcblade
VB Code:
Dim s As String = "Brown" 'Monkey Me.BackColor = Color.FromName(s)
cheers master ;)
Hi,
Many thanks to you both.:wave: