Hello,
I'd like to create a custom header for the printing of a daily, weekly, or monthly calendar.
I have set IncludeDateHeaderArea = false
How do I go about extracting the text that was in the header area so I can place it in my custom header, for example July 2017 ?
Thanks in advance
Hello Anthony,
If you need to show some static text you may set a Header for your print document like this:
this.ultraSchedulePrintDocument1.IncludeDateHeaderArea = false;this.ultraSchedulePrintDocument1.Header.Height = 30;this.ultraSchedulePrintDocument1.Header.TextLeft = "SOME CUSTOM TEXT";this.ultraSchedulePrintDocument1.Header.Appearance.FontData.Bold = DefaultableBoolean.True;this.ultraSchedulePrintDocument1.Header.Appearance.FontData.SizeInPoints = 19;
However, if what you need is some custom text, depending on what is shown originally in date header area you will need to implement your own Creation Filter. There you can add new UIElements as you need and remove the unnecessary ones. Attached is a sample project where I am showing both approaches, considering PrintStyle is set to its default value – Daily.
Please check my sample and let me know if this is what you are looking for, or if I am missing something.
Thank you, this is pretty close to what I was looking for.
My final question would be is there any way to extract the DateHeaderArea text so that I could use it in the custom header.
So where you have:
ultraSchedulePrintDocument1.Header.TextLeft = "SOME CUSTOM TEXT"
I could do something like:
ultraSchedulePrintDocument1.Header.TextLeft = "SOME CUSTOM TEXT " + dateHeaderAreaDateElement.Text
Thank you.
The final answer is that I can't do what I want to do the way I want to do it because the methods are internal.
We want to remove the DateHeaderArea from our monthly calendar printouts to save space so we can get fit as many appointments as possible on the print out.
I wrote my own work around to get the data I want into the custom header. We have a daily, weekly, and monthly view and have variables to tell us which mode the calendar is in prior to printing.
if ( _isDayViewLoaded ) { _headerTextForPrinting += uCalDay.VisibleDays[0].Date.ToShortDateString(); } else if ( _isWeekViewLoaded ) { _headerTextForPrinting += uCalWeek.FirstVisibleDay.Date.ToShortDateString() + " - " + uCalWeek.FirstVisibleDay.Date.AddDays( 6 ).ToShortDateString(); } else if ( _isMonthViewLoaded ) { _headerTextForPrinting += calendarInfo.ActiveDay.Date.ToString( "MMMM yyyy" ); }
ultraSchedulePrintDocument1.Header.TextLeft = _headerTextForPrinting
There is no easy way to get the DateHeaderArea text. What we are doing internally is next. UltraSchedulePrintDocument has private property PrintManager. Depending on the PrintStyle PrintManager creates internally date header info of type DateHeaderInfoDaily, or DateHeaderInfoWeekly, or DateHeaderInfoMonthly and etc. The text you are looking for is in DateCaption internal property of date header info class. As all of these are private/internal properties you cannot get the string you need, but from a lot of reflection. One more thing. If you set IncludeDateHeaderArea to false date header is not created at all. As a result DateCaption, the property which contains the text you need, is not populated.
To summarize – if you need to show what DateHeaderArea would show you should set IncludeDateHeaderArea to true. As long as you do this, and you need to change the content of DateHeaderArea you should implement a custom Creation Filter.
In the sample I had sent you I showed you how to achieve this. Therefore, please let me know why this approach is not working in your scenario?