Set programatically the title to the viewer form in XtraReport

Sebastian picture Sebastian · Sep 9, 2009 · Viewed 10.9k times · Source

Does anybody know how to set the title to the form viewer when showing an XtraReport document? The scenario is the following:

I have an XtraReport report configured, I show it calling the ShowPreviewDialog method, a viewer form opens and shows the document. I need to set the title to this viewer form and can't find the property or way to accomplish this.

Thanks in advance.

Answer

Andrew Burns picture Andrew Burns · Sep 22, 2009

EDIT: Apparently if you do not call CreateDocument it will appear to work sometimes, other times not. So Make sure it is there (it was missing in my first post).

I believe that Kyle's answer is not correct. It appears that you can access the form, it is just not intuitive. As Pierre pointed out, there are valid reasons to create your own form, but if you are find with the default and just want to customize the title then try:

using(var rpt = new XtraReport1())
{
   rpt.PrintingSystem.PrintPreviewFormEx.Text = "My Custom Caption";
   rpt.CreateDocument();
   rpt.ShowPreviewDialog();
}