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).
Comments