11,579 questions
For example :
Color myColor = textBox26.BackColor;
int nColorWin32 = ColorTranslator.ToWin32(myColor);
textBox26.Text = string.Format("{0:X8}", nColorWin32);
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
how can i convert the system drawing color to hex ?? i tried the below listed code but it gives 00000000 always
Color myColor = textBox26.BackColor;
System.ComponentModel.TypeConverter converter =
System.ComponentModel.TypeDescriptor.GetConverter(myColor);
string colorAsString = converter.ConvertToString(textBox26.BackColor);
int ColorValue = Color.FromName(colorAsString).ToArgb();
textBox26.Text= string.Format("{0:x6}", ColorValue);
For example :
Color myColor = textBox26.BackColor;
int nColorWin32 = ColorTranslator.ToWin32(myColor);
textBox26.Text = string.Format("{0:X8}", nColorWin32);