ColorTranslator.ToOle(Color) Metod

Definition

Översätter den angivna Color strukturen till en OLE-färg.

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

Parametrar

c
Color

Strukturen Color som ska översättas.

Returer

OLE-färgvärdet.

Exempel

Följande exempel är utformat för användning med Windows Forms och kräver PaintEventArgse, vilket är en parameter för händelsehanteraren Paint. Koden översätter en Color struktur till ett heltal som representerar en OLE-färg och visar sedan en meddelanderuta med den resulterande strängen.

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

Gäller för