Condividi tramite


ColorTranslator.ToHtml(Color) Metodo

Definizione

Converte la struttura di Color specificata in una rappresentazione di colore 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 tradurre.

Restituisce

Stringa che rappresenta il colore HTML.

Esempio

L'esempio seguente è progettato per l'uso con Windows Form e richiede PaintEventArgse, che è un parametro del gestore eventi Paint. Il codice converte una struttura Color in una rappresentazione di stringa di un colore HTML e quindi visualizza 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 Color in una rappresentazione di stringa di un colore HTML. Si tratta del nome comunemente usato di un colore, ad esempio "Red", "Blue" o "Green" e non di una rappresentazione di stringa di un valore di colore numerico, ad esempio "FF33AAA".

Si applica a