One of the interesting features of our reporting tools is the ability to manipulate report parameters at run-time and at design-time (for both the developer AND the client). A neat little feature that is coming up in v2010 vol 2 is support for custom enumerations in report parameters.
Consider the following type definition as the data source for a report:
1: public enum Gender
2: {
3: Male,
4: Female
5: }
6:
7: public enum PayGrade
8: {
9: Miniscule,
10: Decent,
11: Good,
12: Billionaire
13: }
14:
15: public class Person : XPObject
16: {
17: public string Name { get; set; }
18: public Gender Gender { get; set; }
19: public DateTime BirthDate { get; set; }
20: public PayGrade Pay { get; set; }
21: }

Now when adding parameters, the combo box for the value of the particular enum contains the actual values available in the same. This feature is also available in the report’s Filter String Editor:

Here’s how to do it:
Step 1: Create a custom report design extension:
1: public class PersonReportExtension : ReportDesignExtension
2: {
3: public PersonReportExtension()
4: {
5:
6: }
7:
8: public override void AddParameterTypes(IDictionary<Type, string> dictionary)
9: {
10: base.AddParameterTypes(dictionary);
11: dictionary.Add(typeof(Gender), "Person's Gender");
12: dictionary.Add(typeof(PayGrade), "Person's Pay");
13: }
14: }
Step 2: Register the design extension:
1: ReportDesignExtension
2: .RegisterExtension(new PersonReportExtension(), "PersonEnums");
Step 3: Set the appropriate data source for a new report:
1: XPCollection<Person> source = new XPCollection<Person>();
2: report = new XtraReport();
3: report.DataSource = source;
Step 4: Associate a report with the custom extension:
1: ReportDesignExtension
2: .AssociateReportWithExtension(report, "PersonEnums");
Calling report.ShowDesignerDialog() will then have all of the enum associated goodness.
As always, if you have any questions and/or comments feel free to let me know.
Seth Juarez
Email: sethj@devexpress.com
Twitter: @SethJuarez
Free DevExpress Products – Get Your Copy Today
The following free DevExpress product offers remain available. Should you have any questions about the free offers below, please submit a ticket via the
DevExpress Support Center at your convenience. We’ll be happy to follow-up.