BLOG.CSHARPHELPER.COM: Enumerate HatchStyle values and display samples of them in C#
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).
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
Good stuff. Think you have put BM_WID where you meant BM_HGT at lines 81 & 95.
Reply to this
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