Alex Gordon
Alex Gordon

Reputation: 60912

invalid cast exception, storing colordialog value in textbox

why do i get an error here?

TextBox1.Text = TextBox1.Text & Str(ColorDialog1.Color)

Upvotes: 0

Views: 247

Answers (1)

Nathan W
Nathan W

Reputation: 55512

Try:

TextBox1.Text = TextBox1.Text & Str(ColorDialog1.Color.ToString())

http://msdn.microsoft.com/en-us/library/system.drawing.color_members.aspx

Color is a type that stores information about a color, so you have to call ToString() to convert the value to a string.

Upvotes: 2

Related Questions