I need to Genrate the report of my listbox item it will genrate but at end few item not fit property.
Can anyone explain me how to generate report of listbox item in wpf.
Please reply ASP
Thanks
Anil
Hello Anil,
As I have mentioned previously ListBox control does not have paging functionality. This is the reason why all the contents of it are not fitting in the generated report and thus are not shown in the report preview. The current source code does not support paging in ListBox.
As an alternative, you can create a word document like I suggested and preview that using the PrintDialog.
Please let me know if you have any questions.
Thanks for reply,
I added code above but what i want is not same
public PrintPreview(ListBox lstCollection) { this.lstCollection = lstCollection; InitializeComponent(); Report report = new Report(); EmbeddedVisualReportSection section = new EmbeddedVisualReportSection(lstCollection); report.Sections.Add(section); printPreview.GeneratePreview(report, false, true);
}
This code i write for Preview, but i create single page and many Data not fit
While creating a sample for exporting the ListBox items into a word document using DataPresenter WordWriter object I realized that there is a much simpler way to achieve this.
You can create a WordDocument through code and add the ListBox items to it by doing something like this:
[Code]
using Infragistics.Documents.Word;WordDocumentWriter docWriter = WordDocumentWriter.Create(@"C:\TestWordDoc.docx");docWriter.Unit = UnitOfMeasurement.Inch;docWriter.DocumentProperties.Title = "Sample Document";docWriter.StartDocument();docWriter.StartParagraph();docWriter.AddTextRun("Title");foreach (var str in listBox1.Items) { docWriter.AddTextRun(str); docWriter.AddNewLine(); }docWriter.EndParagraph();docWriter.EndDocument();docWriter.Close();
[/Code]
And then you can use PrintDialog to print preview this word document.
Please try the above and let me know if I may be of further assistance.
Hello Sahaja Thank for reply,
Can you Share one sample , in that listbox item export to word and genrate Preview.
ListBox will generate report with all its contents. However, as it does not support paging functionality few items that are in the end might not fit into the report. This is expected behavior. As an alternative, you can export the ListBox contents into a word document. To implement this, you can refer to our Exporting Data to Word help document here.
Please let me know if I may be of further assistance.