ColorTranslator.ToHtml(Color) 메서드

정의

지정된 Color 구조체를 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

매개 변수

c
Color

변환할 Color 구조체입니다.

반환

HTML 색을 나타내는 문자열을 반환합니다.

예제

다음 예제는 Windows Forms 사용하도록 설계되었으며 이벤트 처리기의 매개 변수 Paint 인 가 필요합니다.PaintEventArgse 코드는 구조를 HTML 색의 문자열 표현으로 변환 Color 한 다음 결과 문자열이 있는 메시지 상자를 표시합니다.

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

설명

이 메서드는 Color 구조를 HTML 색의 문자열 표현으로 변환합니다. "FF33AA"와 같은 숫자 색 값의 문자열 표현이 아닌 "빨강", "파란색" 또는 "녹색"과 같은 일반적으로 사용되는 색 이름입니다.

적용 대상