Exemplo n.º 1
0
    private void btnSelectColor_Click(object sender, System.EventArgs e)
    {
        // Initialize CustomColors with an array of integers.
        // Note that these colors aren't in the same format
        // .NET colors -- these are the old VB6-type
        // color values. For example, 0 is Black, 255 is Red,
        // and so on. You can use the VB6 RGB function to create
        // these values.
        // For this example, put Red, Green, and Blue in the custom
        // colors section.



        try
        {
            // Initialize the selected color
            // to match the color currently used
            // by the TextBox's foreground color.
            // The default is Black.

            cdlgText.Color = txtFileContents.ForeColor;

            // Fill the custom colors on the dialog box
            // with the array you've supplied. This is,
            // of course, totally optional.

            cdlgText.CustomColors = CustomColors;

            // Allow the user to create custom colors?
            // The default is true.

            cdlgText.AllowFullOpen = true;

            // Display all of the basic colors?
            // The default is false.

            cdlgText.AnyColor = true;

            // if true, dialog box displays with the custom
            // color settings side open, well.
            // The default is false.

            cdlgText.FullOpen = false;

            // Restrict users to solid colors only.
            // The default is false.

            cdlgText.SolidColorOnly = true;

            // if ShowHelp is true, the control will display its Help
            // button, and you can react to the control's
            // HelpRequest event.
            // The default is false.

            cdlgText.ShowHelp = true;

            if (cdlgText.ShowDialog() == DialogResult.OK)
            {
                txtFileContents.ForeColor = cdlgText.Color;

                // Store the custom colors for future
                // use.

                CustomColors = cdlgText.CustomColors;
            }

            // Reset all the colors in the dialog box.
            // This isn't necessary, but it does
            // make sure the dialog box is in a
            // known state for its next use.

            cdlgText.Reset();
        }

        catch (Exception exp)
        {
            MessageBox.Show(exp.Message, this.Text);
        }
    }
Exemplo n.º 2
0
        private void bgOut_Click(object sender, EventArgs e)
        {
            ColorDialog MyDialog = new ColorDialog();

            MyDialog.FullOpen = true;
            MyDialog.Color = l_out_mex.BackColor;

            if (MyDialog.ShowDialog() == DialogResult.OK)
            {
                l_out_mex.BackColor = MyDialog.Color;
                Properties.Settings.Default.colorMex = MyDialog.Color;
            }
            MyDialog.Reset();
        }