20 December, 2014

ColorDailogBox

private void ForegroundButton_Click(object sender, EventArgs e)
{
    ColorDialog colorDlg = new ColorDialog();
    colorDlg.AllowFullOpen = false;
    colorDlg.AnyColor = true;
    colorDlg.SolidColorOnly = false;
    colorDlg.Color = Color.Red;
                    
    if (colorDlg.ShowDialog() == DialogResult.OK)
    {
        textBox1.ForeColor = colorDlg.Color;
        listBox1.ForeColor = colorDlg.Color;
        button3.ForeColor = colorDlg.Color;
    }
}

private void BackgroundButton_Click(object sender, EventArgs e)
{
    ColorDialog colorDlg = new ColorDialog();
    if (colorDlg.ShowDialog() == DialogResult.OK)
    {
        textBox1.BackColor = colorDlg.Color;
        listBox1.BackColor = colorDlg.Color;
        button3.BackColor = colorDlg.Color;
    }
}

No comments:

Post a Comment