ColorTranslator.ToHtml(Color) Metodo
Definizione
Importante
Alcune informazioni sono relative alla release non definitiva del prodotto, che potrebbe subire modifiche significative prima della release definitiva. Microsoft non riconosce alcuna garanzia, espressa o implicita, in merito alle informazioni qui fornite.
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
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
Commenti e suggerimenti
https://aka.ms/ContentUserFeedback.
Presto disponibile: Nel corso del 2024 verranno gradualmente disattivati i problemi di GitHub come meccanismo di feedback per il contenuto e ciò verrà sostituito con un nuovo sistema di feedback. Per altre informazioni, vedereInvia e visualizza il feedback per