ColorTranslator.ToOle(Color) 方法

定义

将指定的 Color 结构翻译成 OLE 颜色。

public:
 static int ToOle(System::Drawing::Color c);
public static int ToOle (System.Drawing.Color c);
static member ToOle : System.Drawing.Color -> int
Public Shared Function ToOle (c As Color) As Integer

参数

c
Color

要转换的 Color 结构。

返回

OLE 颜色值。

示例

下面的示例旨在与 Windows 窗体 一起使用,它需要 PaintEventArgse,它是 事件处理程序的Paint一个参数。 该代码将 Color 结构转换为表示 OLE 颜色的整数,然后显示包含生成的字符串的消息框。

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.ToString() );
   }
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.ToString());
}
Public Sub ToOle_Example(ByVal 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

适用于