James

James

  • NA
  • 3
  • 0

Setting SolidBrush color with a ColorDialog

Dec 15 2009 3:25 PM
Hey

I am new to c# and need some assistance with something I am trying to do.  I want to use a Color Dialog box to let the user change the color of a brush when painting a grid.  I have used a button, so when it is clicked on the form, the Color Dialog loads up.  However when I select a new color and then paint on the grid, the color hasn't changed.  I have put the code below.  Could anyone explain where I am going wrong, or what I need to do to make sure the grid is painted witht the newly selected color please.

         private void button2_Click(object sender, EventArgs e)
{
SolidBrush myBrush = new SolidBrush(Color.Empty);
ColorDialog diag = new ColorDialog();
diag.ShowDialog();
pictureBox1.Refresh();
Refresh();

}
If anyone can give me some assistance on how I can achieve what I want to do then I would be very grateful.  I just need to understand what code I need to add or where I have gone wrong at the minute.  Really appreciate anyones times.

J


Answers (4)