I am building a fairly plain and simple car registration system.
When the user is on the screen on which they edit all the vehicle/owner/title data, they often want to print either a certificate of registration or a certificate of title.
I'm using the DevExpress xtraReport tool here and have built a report that should work just fine. And of course the tool is capable of binding to business objects which is the major reason I'm using it. Sounds good so far, eh?
My problem is that the report tool can only bind to objects that implement IList (which doesn't seem such a harsh requirement), but when users are editing my Vehicle object, it's an ERO - which, of course, doesn't implement IList.
[If you don't use an IList-capable report tool, just imagine that you want to display your ERO's properties in one row of a datagrid in which case you run into exactly the same obstacle I face here.]
I guess I can build a child collection (or perhaps better, a single-member R-O Collection object) to clone my ERO's properties just for the report. But this seems quite the kludge, doesn't it?!!
Isn't there a more elegant way to solve this? For example, could I make my Vehicle ERO implement IList well enough for the report to bind to its properties? And, if so, how? And if not, are there other appealing options that I'm too dense to see yet?
Thanks in advance,
RockfordLhotka:
Just put your object into any collection type that implements IList (an ArrayList perhaps), and away you go.
I used an ArrayList. It was simple as can be and worked perfectly on the first try. Thanks for the great tip!
For other new DevExpress xtraReport users who may be lurking - I declared the ArrayList Public in my xtraReport file (sure I could have written a property set procedure instead). Then in the button click code from my form I just (1)create the local ArrayList, (2).Add my BO to it, (3)create the local report object, (4) assign my local ArrayList to the Report's one, and (5)call ShowPreview.
Of course creating the bound controls on the report will be a task of varying difficulty in different circumstances. But in my case, I had built the report with Access (having built a query for it) and simply imported it into a new xtraReport. I never had to write a single line of code to handle the binding. This feels pretty efficient to me!!
Thanks again, Rocky.
Copyright (c) Marimer LLC