ArcObjects Library Reference  (Display)    

IColor Example

The first three lines of code below declares an IColor variable and sets it to a new RGBColor object. Then the Visual Basic RGB function is used to set the RGB property to get a mixed color.

[Visual Basic 6.0]
Dim myColor As IColor Set myColor = New RGBColor myColor.RGB = RGB(255,255,155)

This could also be accomplished using the Red, Green, and Blue properties on the IRGBColor interface

  Dim myColor As IRGBColor
  Set myColor = New RGBColor
  myColor.Red = 255
  myColor.Blue = 255
  myColor.Green = 15

Aside from the RGBColor object, you can set an IColor to use any of the other color CoClasses.

  'Set myColor = New HSVColor
  'Set myColor = New HLSColor
  'Set myColor = New CMYKColor
  'Set myColor = New GrayColor

If you need to convert an IColor Object to an OLE Color (to use in your UI components)

  MyControl.backGroundColor = myColor.RGB

[Visual Basic .NET, C#, C++]
No example is available for Visual Basic .NET, C#, or C++. To view a Visual Basic 6.0 example, click the Language Filter button Language Filter in the upper-left corner of the page.