hi rodel. Yes you really dont need to include the designer control in most apps. The only time you really need it is when you have to do the layout of a particular report. Normally when you're done with the layout of a report you have to store the report schema somewhere, either to a file, a string item in a resource file, or a table in a database. When it's time to run the report all you have to do is feed this schema (a string value) to a ReportComposer object so it will know how to format your report. eg: reportComposer.Execute(schema)
When I was designing the ReportComposer, I wrestled with the idea of including a Datasource property. It would have been nice since all you have to do is set the Datasource property to a DataSet or an IList perhaps then call the Execute method. But things got too complicated in a hurry and so I settled to calling two events whenever the ReportComposer needed some data. These two events are InitData and ReadData.
Here's an example of how to print a report programmatically.
void PrintReport()
{
ReportComposer composer = new ReportCOmposer();
composer.InitData += OnInitData;
composer.ReadData += OnReadData;
composer.Execute(GetSchema());
PrintService printService = new PrintService(composer);
printService.PrintAll();
}
void OnInitData(object sender, ReportComposerEventArgs e)
{
e.Count = GetRowCount();
}
void OnReadData(object sender, ReportComposerEventArgs e)
{
e.Value = GetValue(e.ColumnName, e.Index)
}
string GetSchema()
{
// return report schema
}
int GetRowCount()
{
// return row count
}
object GetValue(string name, int index)
{
// return value from datasource
}
Regarding the issue of exposing an API so you can programmatically layout a report, I thought they're unnecessary since it really defeats the purpose of making the whole process of crafting a report as painless as possible. What I have is a ReportSchema class which converts the report schema (an xml document) into its runtime equivalent eg: groups, bands, widgets.
I will be posting a Quickstart document as soon as I finish writing the whole thing. About licensing issues, ClassicReports is freeware and I have no intention of suing anybody. I have not tested this on POS printers so no comment on that. :)