次の方法で共有


ColorTranslator.ToOle メソッド

指定した Color 構造体を OLE カラーに変換します。

Public Shared Function ToOle( _
   ByVal c As Color _) As Integer
[C#]
public static int ToOle(Colorc);
[C++]
public: static int ToOle(Colorc);
[JScript]
public static function ToOle(
   c : Color) : int;

パラメータ

  • c
    変換対象の Color 構造体。

戻り値

OLE カラー値。

使用例

[Visual Basic, C#] 次の例は、Windows フォームでの使用を意図してデザインされており、 Paint イベント ハンドラのパラメータである PaintEventArgs e が必要です。このコードでは、 Color 構造体を OLE カラーを表す整数に変換し、メッセージ ボックスにその文字列を表示します。

 
Public Sub ToOle_Example(e As PaintEventArgs)
' Create an instance of a Color structure.
Dim myColor As Color = Color.Green
' Translate myColor to an OLE color.
Dim oleColor As Integer = ColorTranslator.ToOle(myColor)
' Show a message box with the value of htmlColor.
MessageBox.Show(oleColor.ToString())
End Sub
        
[C#] 
public void ToOle_Example(PaintEventArgs e)
{
// Create an instance of a Color structure.
Color myColor = Color.Red;
// Translate myColor to an OLE color.
int oleColor = ColorTranslator.ToOle(myColor);
// Show a message box with the value of oleColor.
MessageBox.Show(oleColor);
}
        

[C++, JScript] C++ および JScript のサンプルはありません。Visual Basic および C# のサンプルを表示するには、このページの左上隅にある言語のフィルタ ボタン 言語のフィルタ をクリックします。

必要条件

プラットフォーム: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 ファミリ

参照

ColorTranslator クラス | ColorTranslator メンバ | System.Drawing 名前空間