Creating a report for a ListView

Creating a report for a ListView

Forum member · Apr 16, 2008
Hi all, I have an application with a ListView, whose contents the user can edit at run-time. I want to save the content of the ListView to a PDF-file. DPLX files look very useful for this purpose, but all I can find are examples on how to use them in combination with a database. Is there another way to do this? Thanks in advance, Frances

Re: Creating a report for a ListView

Forum member · Apr 16, 2008
Hi all, I've implemented a solution for my problem, but I wonder if it can be done in another way? private void pdfButton_Click(object sender, RoutedEventArgs e) { DocumentLayout report = new DocumentLayout( "C:\\Test.dplx" ); Query query1 = report.GetQueryById( "Query1" ); query1.OpeningRecordSet += query1_OpeningRecordSet; Document document = report.Run(); document.Draw(@"C:\report.pdf"); } void query1_OpeningRecordSet(object sender, OpeningRecordSetEventArgs args) { DataTable dataTable = new DataTable(); DataColumn col = new DataColumn("A", Type.GetType("System.String")); dataTable.Columns.Add(col); col = new DataColumn("B", Type.GetType("System.String")); dataTable.Columns.Add(col); foreach (StringClass str in mainGrid.ItemsSource) { System.Data.DataRow row = dataTable.NewRow(); row[0] = str.A; row[1] = str.B; dataTable.Rows.Add(row); } args.RecordSet = new DataTableRecordSet(dataTable); } Thanks in advance, Frances

Re: Creating a report for a ListView

Support · Apr 16, 2008
Hello Frances, Yes, what you are doing is the only way to do this. You will have to use the OpeningRecordSet event of the query object to set the data source when not using any database. You will have to create a data table and assign it to the record set in this event. Thanks, ceTe Software Support Team.