Język

ColorTranslator.ToHtml(Color) Metoda

Definicja

Tłumaczy określoną Color strukturę na reprezentację koloru ciągu 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

Parametry

c
Color

Struktura Color do przetłumaczenia.

Zwraca

Ciąg reprezentujący kolor HTML.

Przykłady

Poniższy przykład został zaprojektowany do użycia z formularzami systemu Windows i wymaga PaintEventArgseparametru Paint programu obsługi zdarzeń. Kod tłumaczy Color strukturę na ciąg reprezentujący kolor HTML, a następnie wyświetla pole komunikatu z wynikowym ciągiem.

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

Uwagi

Ta metoda tłumaczy Color strukturę na ciąg reprezentujący kolor HTML. Jest to powszechnie używana nazwa koloru, takiego jak "Czerwony", "Niebieski" lub "Zielony", a nie reprezentacja ciągu wartości koloru liczbowego, na przykład "FF33AA".

Dotyczy