Share via


ColorDialog Class

Methods | This Package | All Packages

Represents a common dialog box that displays available colors along with controls that let the user define custom colors.

Component
  |
  +--CommonDialog
    |
    +--ColorDialog

package com.ms.wfc.ui

public class ColorDialog
extends
CommonDialog****

Remarks

Use the showDialog method to show the dialog box. Use the getColor method to get the color the user selected.

The following example opens a Color dialog box and sets the background color for the form to color the user selects:

private void btnColor_click(Object source, Event e)
{
    ColorDialog cd = new ColorDialog();
    cd.setAllowFullOpen(true); //enables the Define Custom Colors button
    cd.setColor(Color.RED);  //sets the color initially chosen in the dialog box to red
    int dlgResult = cd.showDialog();
    if (dlgResult == DialogResult.OK) {
        Color objColor = cd.getColor(); //gets the color the user chose
        this.setBackColor(objColor);  //sets the form background color to the chosen color
    }
}