Zebra0.com

csharp dialogs


Text of video

Write the code as shown below:

private void mnuColor_Click(object sender, EventArgs e)
{
  // This is a different way to determine if the user clicked cancel.
  // Show the color dialog and store result (Ok or Cancel).
  DialogResult result = colorDialog1.ShowDialog();
  // See if user pressed ok.
  if (result == DialogResult.OK)
  {
     // Set form background to the selected color.
     this.BackColor = colorDialog1.Color;
  }
}

private void toolStripColor_Click(object sender, EventArgs e)
{
   mnuColor_Click(sender, e);
}

Experiment: After the font changes, or the greeting changes, or the size of the form changes, center the greeting.
After the picture changes, or when the form changes size, center the picture.

End of lesson, Next lesson: forms in C#