ColorTranslator.ToHtml(Color) Método

Definición

Convierte la estructura Color especificada en una representación de cadena de un color HTML.

public:
 static System::String ^ ToHtml(System::Drawing::Color c);
public static string ToHtml (System.Drawing.Color c);
static member ToHtml : System.Drawing.Color -> string
Public Shared Function ToHtml (c As Color) As String

Parámetros

c
Color

Estructura Color que se va a convertir.

Devoluciones

Cadena que representa el color HTML.

Ejemplos

El ejemplo siguiente está diseñado para su uso con Windows Forms y requiere PaintEventArgse, que es un parámetro del Paint controlador de eventos. El código traduce una Color estructura a una representación de cadena de un color HTML y, a continuación, muestra un cuadro de mensaje con la cadena resultante.

public:
   void ToHtml_Example( PaintEventArgs^ /*e*/ )
   {
      // Create an instance of a Color structure.
      Color myColor = Color::Red;

      // Translate myColor to an HTML color.
      String^ htmlColor = ColorTranslator::ToHtml( myColor );

      // Show a message box with the value of htmlColor.
      MessageBox::Show( htmlColor );
   }
public void ToHtml_Example(PaintEventArgs e)
{
    // Create an instance of a Color structure.
    Color myColor = Color.Red;
             
    // Translate myColor to an HTML color.
    string htmlColor = ColorTranslator.ToHtml(myColor);
             
    // Show a message box with the value of htmlColor.
    MessageBox.Show(htmlColor);
}
Public Sub ToHtml_Example(ByVal e As PaintEventArgs)

    ' Create an instance of a Color structure.
    Dim myColor As Color = Color.Red

    ' Translate myColor to an HTML color.
    Dim htmlColor As String = ColorTranslator.ToHtml(myColor)

    ' Show a message box with the value of htmlColor.
    MessageBox.Show(htmlColor)
End Sub

Comentarios

Este método traduce una Color estructura a una representación de cadena de un color HTML. Este es el nombre usado habitualmente de un color, como "Rojo", "Azul" o "Verde", y no la representación de cadena de un valor de color numérico, como "FF33AAA".

Se aplica a