ColorConverter Class
Converts colors from one data type to another. Access this class through the TypeDescriptor.
Assembly: System.Drawing (in System.Drawing.dll)
When converting from a string to a Color the ColorConverter expects the unqualified color name; otherwise, an exception will occur in the conversion process. For example, you should pass "Blue", not "System.Drawing.Color.Blue" or "Color.Blue", to the ConvertFrom method.
The following code example demonstrates how to use the ConvertToString method. This example is designed to be used with Windows Forms. Paste this code into a form and call the ShowColorConverter method when handling the form's Paint event, passing e as PaintEventArgs.
Private Sub ShowColorConverter(ByVal e As PaintEventArgs) Dim myColor As Color = Color.PaleVioletRed ' Create the ColorConverter. Dim converter As System.ComponentModel.TypeConverter = _ System.ComponentModel.TypeDescriptor.GetConverter(myColor) Dim colorAsString As String = _ converter.ConvertToString(Color.PaleVioletRed) e.Graphics.DrawString(colorAsString, Me.Font, _ Brushes.PaleVioletRed, 50.0F, 50.0F) End Sub
System.ComponentModel.TypeConverter
System.Drawing.ColorConverter
System.Web.UI.WebControls.WebColorConverter
Windows 7, Windows Vista, Windows XP SP2, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP Starter Edition, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003, Windows Server 2000 SP4, Windows Millennium Edition, Windows 98
The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.