Getsuyodev, Programming is mainly used when constructing an application. Programming requires knowledge of application domains, algorithms, and programming language expertise. Programming can be developed in different logic based on developer knowledge.

C# Color Dialog Box



Several classes implement common dialog boxes, such as color selection , print setup etc.

A ColorDialog object is a dialogue box with a list of colours that are defined for the display system. The user can select or create a particular colour from the list, which is then reported back to the application when the dialogue box exits. You can invite a colour dialogue box by calling the ShowDialog() method.

ColorDialog dlg = new ColorDialog();
dlg.ShowDialog();

The following C# program invites a colour dialogue box and retrieves the selected colour to a string.

using System;
using System.Drawing;
using System.Windows.Forms;

namespace WindowsFormsApplication1
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            ColorDialog dlg = new ColorDialog();
            dlg.ShowDialog();

            if (dlg.ShowDialog() == DialogResult.OK)
            {
                string str = null;
                str = dlg.Color.Name;
                MessageBox.Show (str);
            }
        }
    }
}

Comments are closed.

This website uses cookies to improve your experience. We'll assume you're ok with this, but you can opt-out if you wish. Accept Read More