tailieunhanh - Programming Microsoft Windows with C# phần 9

Hình 5-10. Các trang sau khi trình web CustomEventTextBox hình thức cửa sổ Properties Visual Studio đã làm công việc của nó trong hệ thống dây điện cho các sự kiện tùy chỉnh. Nó đủ thông minh để nhận ra chúng tôi đã sử dụng TextChangedEventHandler như là một đại biểu để bọc các phương pháp xử lý | prnres The foreach statement loops through all the items of the PrinterResolutions collection in the Printersettings object associated with the PageSettings object. When there s a match the code sets the PrinterResolution property. You need to set the PrinterResolution property of PageSettings from precreated PrinterResolution objects because the PrinterResolution class has no public constructor. There aren t many occasions when your program will want to change the PaperSource or PaperSize property. However suppose you implement a mail-merge facility and you want to alternately print letters and envelopes in one print job. You would need to change the PaperSource and PaperSize properties accordingly based on specifications the user made in the application. The PaperSize property is not affected by the Landscape property. If the Landscape property is false the Bounds property Width and Height will equal the Width and Height properties of the PaperSize property. If Landscape is true the Bounds Width and Height properties will be swapped. The PaperSize properties will not. So far we haven t gotten to the point where we can actually print something. That job requires defining an object of type PrintDocument. Defining a Document A print job consists of one or more pages printed on a particular printer and is represented by the PrintDocument class. PrintDocument has only a default constructor PrintDocument Constructor PrintDocumentO Generally a program begins the process of printing by creating an object of type PrintDocument PrintDocument prndoc new PrintDocumentO You could create this object anew for each print job. However if you re using the standard print dialog boxes or some other means of allowing the user to select printers and printer options you probably want to retain those settings in the PrintDocument object and use the same instance for the duration of the program. In that case you d define prndoc as a field and create it only .

TỪ KHÓA LIÊN QUAN