Enumerate HatchStyle values and display samples of them in C#

The article Use reflection to list the values defined by an enum in C# shows how to list the values in an enumeration. This example uses the GetEnumValues function described in that article to list the values defined by the HatchStyle enumeration. It then uses the following code to loop through those values and display samples.

// Display the names of the HatchStyle values.
private void Form1_Load(object sender, EventArgs e)
{
// Get a list of the HatchStyles.
List hatch_styles = GetEnumValues();
foreach (HatchStyle hatch_style in hatch_styles)
{
DisplayHatchStyle(hatch_style);
}
}

The DisplayHatchStyle function displays a sample hatch style. It creates a Panel and adds it to the form's FlowLayoutPanel control. Inside the Panel it places a Label giving the hatch style's name and a PictureBox filled with that hatch style. See the code for the details (or see the article Display images of the cursors avaiable in C#, which displays cursors in a similar manner).

   

 

What did you think of this article?




Trackbacks
  • No trackbacks exist for this post.
Comments

  • 8/14/2012 7:11 PM Oliver Bock wrote:
    Good stuff. Think you have put BM_WID where you meant BM_HGT at lines 81 & 95.
    Reply to this
    1. 8/15/2012 3:35 PM Rod Stephens wrote:
      Hi Oliver,

      You're right. By coincidence, the program was only copying part of the image into a different image and displaying the image in a smaller PictureBox. Although the bitmap had the incorrect size, you didn't notice because it was bigger than necessary.

      It's still nice to fix these things. Thanks for pointing this out!
      Reply to this
Leave a comment

Submitted comments are subject to moderation before being displayed.

 Name

 Email (will not be published)

 Website

Your comment is 0 characters limited to 3000 characters.