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

Dim htmlColor As String Dim returnValue As Color returnValue = ColorTranslator.FromHtml(htmlColor)
戻り値
変換した HTML カラーを表す Color 構造体。


次の例は、Windows フォームでの使用を意図してデザインされており、Paint イベント ハンドラのパラメータである PaintEventArgse が必要です。このコードでは、HTML カラー名を Color 構造体に変換し、その色で四角形を塗りつぶします。
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
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: 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.get_Graphics().FillRectangle(new SolidBrush(myColor), 0, 0, 100, 100); } //FromHtml_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.FromHtml メソッドを検索する場合は、下記のリンクをクリックしてください。

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