ColorTranslator.FromHtml メソッドとは? わかりやすく解説

Weblio 辞書 > コンピュータ > .NET Framework クラス ライブラリ リファレンス > ColorTranslator.FromHtml メソッドの意味・解説 

ColorTranslator.FromHtml メソッド

HTMLカラー形式GDI+ Color 構造体変換します

名前空間: System.Drawing
アセンブリ: System.Drawing (system.drawing.dll 内)
構文構文

Public Shared Function FromHtml
 ( _
    htmlColor As String _
) As Color
Dim htmlColor As String
Dim returnValue As Color

returnValue = ColorTranslator.FromHtml(htmlColor)
public static Color FromHtml (
    string htmlColor
)
public:
static Color FromHtml (
    String^ htmlColor
)
public static Color FromHtml (
    String htmlColor
)
public static function FromHtml
 (
    htmlColor : String
) : Color

パラメータ

htmlColor

変換対象HTML カラー文字列形式

戻り値
変換した 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
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照


このページでは「.NET Framework クラス ライブラリ リファレンス」からColorTranslator.FromHtml メソッドを検索した結果を表示しています。
Weblioに収録されているすべての辞書からColorTranslator.FromHtml メソッドを検索する場合は、下記のリンクをクリックしてください。
 全ての辞書からColorTranslator.FromHtml メソッド を検索

英和和英テキスト翻訳>> Weblio翻訳
英語⇒日本語日本語⇒英語
  

辞書ショートカット

すべての辞書の索引

ColorTranslator.FromHtml メソッドのお隣キーワード
検索ランキング

   

英語⇒日本語
日本語⇒英語
   



ColorTranslator.FromHtml メソッドのページの著作権
Weblio 辞書 情報提供元は 参加元一覧 にて確認できます。

   
日本マイクロソフト株式会社日本マイクロソフト株式会社
© 2025 Microsoft.All rights reserved.

©2025 GRAS Group, Inc.RSS