Aracılığıyla paylaş


ColorTranslator.FromHtml(String) Yöntem

Tanım

HTML renk gösterimini GDI+ Color yapısına çevirir.

public:
 static System::Drawing::Color FromHtml(System::String ^ htmlColor);
public static System.Drawing.Color FromHtml (string htmlColor);
static member FromHtml : string -> System.Drawing.Color
Public Shared Function FromHtml (htmlColor As String) As Color

Parametreler

htmlColor
String

Çevrilecek Html renginin dize gösterimi.

Döndürülenler

Color Çevrilmiş HTML rengini veya Empty ise htmlColor değerini temsil eden yapı.null

Özel durumlar

htmlColor geçerli bir HTML renk adı değil.

Örnekler

Aşağıdaki örnek, Windows Forms ile kullanılmak üzere tasarlanmıştır ve olay işleyicisinin bir parametresi olan öğesini gerektirirPaintEventArgse.Paint Kod, HTML renk adını bir Color yapıya çevirir ve ardından dikdörtgeni doldurmak için bu rengi kullanır.

public:
   void FromHtml_Example( PaintEventArgs^ e )
   {
      // Create a string representation of an HTML color.
      String^ htmlColor = "Blue";

      // Translate htmlColor to a GDI+ Color structure.
      Color myColor = ColorTranslator::FromHtml( htmlColor );

      // Fill a rectangle with myColor.
      e->Graphics->FillRectangle( gcnew SolidBrush( myColor ), 0, 0, 100, 100 );
   }
public void FromHtml_Example(PaintEventArgs e)
{
    // Create a string representation of an HTML color.
    string htmlColor = "Blue";
             
    // Translate htmlColor to a GDI+ Color structure.
    Color myColor = ColorTranslator.FromHtml(htmlColor);
             
    // Fill a rectangle with myColor.
    e.Graphics.FillRectangle( new SolidBrush(myColor), 0, 0, 
        100, 100);
}
Public Sub FromHtml_Example(ByVal e As PaintEventArgs)

    ' Create a string representation of an HTML color.
    Dim htmlColor As String = "Blue"

    ' Translate htmlColor to a GDI+ Color structure.
    Dim myColor As Color = ColorTranslator.FromHtml(htmlColor)

    ' Fill a rectangle with myColor.
    e.Graphics.FillRectangle(New SolidBrush(myColor), 0, 0, 100, 100)
End Sub

Açıklamalar

Bu yöntem, Mavi veya Kırmızı gibi bir HTML renk adının dize gösterimini GDI+ Color yapısına çevirir.

Şunlara uygulanır