How can I add titles when printing all printable parts of devexpress components, such as gridcontrol, treelist.
View help and find that you need to use devexpress. xtraprinting. printablecomponentlink to implement this object. That is to say, the print () method of the gridcontrol control cannot be used.
In the devexpress. xtraprinting namespace, you can find a class such as pageheaderfooter. Of course, this class is to set the header and footer. We can use it to set the title or page-related information for printing.
Printingsystem PS = NULL;
Devexpress. xtraprinting. printablecomponentlink link = NULL;
PS = new devexpress. xtraprinting. printingsystem ();
Link = new devexpress. xtraprinting. printablecomponentlink (PS );
PS. Links. Add (Link );
Link. Component = urgridcontrol; // This can be a printable part.
String _ printheader = "my title information ";
Pageheaderfooter phf = link. pageheaderfooter as pageheaderfooter;
Phf. header. content. Clear ();
Phf. header. content. addrange (New String [] {"", _ printheader ,""});
Phf. header. font = new system. Drawing. Font ("", 14, system. Drawing. fontstyle. Bold );
Phf. header. linealignment = brickalignment. Center;
Link. createdocument (); // create a document
PS. previewform. Show (); // Preview
In fact, it is best to use the above method to print in devexpress. When printing, we only need to set different iprintable objects (marked in red above ). Easy to use.