ColorTranslator.ToHtml(Color) 메서드
정의
중요
일부 정보는 릴리스되기 전에 상당 부분 수정될 수 있는 시험판 제품과 관련이 있습니다. Microsoft는 여기에 제공된 정보에 대해 어떠한 명시적이거나 묵시적인 보증도 하지 않습니다.
지정된 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
매개 변수
반환
HTML 색을 나타내는 문자열입니다.
예제
다음 예제는 Windows Forms에서 사용하도록 설계되었으며 Paint 이벤트 처리기의 매개 변수인 PaintEventArgse필요합니다. 이 코드는 Color 구조를 HTML 색의 문자열 표현으로 변환한 다음 결과 문자열이 있는 메시지 상자를 표시합니다.
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"와 같은 숫자 색 값의 문자열 표현이 아니라 "빨강", "파랑" 또는 "녹색"과 같이 일반적으로 사용되는 색 이름입니다.