Happy Codings - Programming Code Examples
Html Css Web Design Sample Codes CPlusPlus Programming Sample Codes JavaScript Programming Sample Codes C Programming Sample Codes CSharp Programming Sample Codes Java Programming Sample Codes Php Programming Sample Codes Visual Basic Programming Sample Codes


CSharp Programming

CSharp > Code Examples

Click on me to change the color

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
Click on me to change the color using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Text; using System.Windows.Forms; public class MainForm : Form { private ColorDialog colorDlg; private Color currColor = Color.DimGray; public MainForm() { CenterToScreen(); colorDlg = new ColorDialog(); this.MouseDown += new MouseEventHandler(MainForm_MouseDown); } void MainForm_MouseDown(object sender, MouseEventArgs e) { if (colorDlg.ShowDialog() != DialogResult.Cancel) { currColor = colorDlg.Color; this.BackColor = currColor; string strARGB = colorDlg.Color.ToString(); MessageBox.Show(strARGB, "Color is:"); } } }