ColorTranslator.ToHtml メソッド
アセンブリ: System.Drawing (system.drawing.dll 内)

Dim c As Color Dim returnValue As String returnValue = ColorTranslator.ToHtml(c)
戻り値
HTML カラーを表す文字列。

このメソッドは、Color 構造体を HTML カラーの文字列形式に変換します。これは "Red"、"Blue"、"Green" など、最もよく使用される色の名前であり、"FF33AA" などの数値によるカラー値ではありません。

次の例は、Windows フォームでの使用を意図してデザインされており、Paint イベント ハンドラのパラメータである PaintEventArgse が必要です。このコードでは、Color 構造体を HTML カラーの文字列形式に変換し、メッセージ ボックスにその文字列を表示します。
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
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 void ToHtml_Example(PaintEventArgs e) { // Create an instance of a Color structure. Color myColor = Color.get_Red(); // Translate myColor to an HTML color. String htmlColor = ColorTranslator.ToHtml(myColor); // Show a message box with the value of htmlColor. MessageBox.Show(htmlColor); } //ToHtml_Example

Windows 98, Windows 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


Weblioに収録されているすべての辞書からColorTranslator.ToHtml メソッドを検索する場合は、下記のリンクをクリックしてください。

- ColorTranslator.ToHtml メソッドのページへのリンク