Aracılığıyla paylaş


ColorTranslator.ToHtml(Color) Yöntem

Tanım

Belirtilen Color yapıyı bir HTML dizesi renk gösterimine çevirir.

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

Parametreler

c
Color

Çevrilecek Color yapı.

Döndürülenler

HTML rengini temsil eden dize.

Örnekler

Aşağıdaki örnek, Windows Forms ile kullanılmak üzere tasarlanmıştır ve olay işleyicisinin Paint bir parametresi olan gerektirir.PaintEventArgse Kod, bir Color yapıyı HTML renginin dize gösterimine çevirir ve ardından sonuçta elde edilen dizeyi içeren bir ileti kutusu gösterir.

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

Açıklamalar

Bu yöntem, bir Color yapıyı HTML renginin dize gösterimine çevirir. Bu, bir rengin "Kırmızı", "Mavi" veya "Yeşil" gibi yaygın olarak kullanılan adıdır ve "FF33AA" gibi sayısal bir renk değerinin dize gösterimi değildir.

Şunlara uygulanır