Đang chuẩn bị liên kết để tải về tài liệu:
Print Labels and Control the Order in Which Records Will Be Printed
Đang chuẩn bị nút TẢI XUỐNG, xin hãy chờ
Tải xuống
In Nhãn và kiểm soát thứ tự mà Records sẽ in tôi cần để có thể ứng dụng của tôi có in nhãn cho người sử dụng danh sách khách hàng của tôi. Đôi khi người sử dụng của tôi cần in nhãn dựa trên mã bưu chính, | 10.6 Print Labels and Control the Order in Which Records Will Be Printed I need to be able to have my application print labels for my user s customer list. Sometimes my user needs to print labels based on the postal code and other times he needs to print labels alphabetically by company name. How do I do this at runtime Technique To accomplish this task you will use the Report Expert to create mailing labels. You then will use code to update the sort order at run-time. Creating the Mailing Labels To create the mailing labels you create a new report and choose Mailing Labels for the type of Expert to use. You then fill in the Data tab which uses Customers for the table and grab the following fields CompanyName ContactName ContactTitle Address Formula @CityRegionPostal Customers.City Customers.Region Customers.PostalCode and Country. You can see how this will look in Figure 10.22. Figure 10.22. Fields that will be used in the mailing labels. After clicking Next you are taken to the tab that allows you to choose which type of label you want to use. For this How-To the Address Avery 5160 is used. Everything else on the page is chosen for you see Figure 10.23 . Figure 10.23. You have control over how your labels look. Now you can just click Finish and the final mailing label report is created see Figure 10.24 . Figure 10.24. These appear in nice mailing label format when they re viewed on a form. Controlling the Sort Order at Runtime To control the sort order at runtime you use properties methods and objects of the ReportDocument. Specifically you traverse down the ReportDocument object model looking at the Database object and moving down to the Fields level. You do this first when you re loading up a combo box with fields that are being used in the report. The following lines of code accomplish this For Each dfCurr In Me.rdHowTo10_6.Database.Tables.Item 0 .Fields Me.cboSortFields.Items.Add dfCurr.Name Next dfCurr is a FieldDefinition object which means it is a field .