Condividi tramite


ColorTranslator.ToHtml(Color) Metodo

Definizione

Converte la struttura Color in una rappresentazione di colore in forma di stringa 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

Parametri

c
Color

Struttura Color da convertire.

Restituisce

Stringa che rappresenta il colore HTML.

Esempio

L'esempio seguente è progettato per l'uso con Windows Forms e richiede PaintEventArgse, che è un parametro del Paint gestore eventi. Il codice converte una struttura in una Color rappresentazione stringa di un colore HTML e quindi mostra una finestra di messaggio con la stringa risultante.

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

Commenti

Questo metodo converte una struttura in una Color rappresentazione stringa di un colore HTML. Questo è il nome comunemente usato di un colore, ad esempio "Rosso", "Blu" o "Verde" e non la rappresentazione stringa di un valore di colore numerico, ad esempio "FF33AAA".

Si applica a