RadScheduler Weekly Print Preview throws run time error - SchedulerWeeklyPrintStyle

4 posts, 0 answers
  1. Richard
    Richard avatar
    32 posts
    Member since:
    Aug 2010

    Posted 28 Jan 2014 Link to this post

    Hi There, 

    I am getting run time error while previewing the weekly style of RadScheduler. This is happening when I use SchedulerWeeklyPrintSTyle.GroupType = SchedulerPrintGroupType.Resource and changing layout to "2 pages/week". If the layout is "1 page / week", then it is showing the preview as expected.  

    Please see the attached Print Setting window to see the settings that throws the run time error. 

    ************** Exception Text **************
    System.ArgumentOutOfRangeException: Index was out of range. Must be non-negative and less than the size of the collection.
    Parameter name: index
       at System.ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument argument, ExceptionResource resource)
       at System.ThrowHelper.ThrowArgumentOutOfRangeException()
       at System.Collections.Generic.List`1.get_Item(Int32 index)
       at Telerik.WinControls.UI.SchedulerWeeklyPrintStyle.GetPageResource(Int32 pageNumber)
       at Telerik.WinControls.UI.SchedulerPrintStyle.DrawTopArea(Rectangle drawingArea, Graphics graphics, Int32 pageNumber)
       at Telerik.WinControls.UI.SchedulerPrintStyle.DrawPage(Graphics graphics, Rectangle drawingArea, Int32 pageNumber)
       at Telerik.WinControls.UI.RadScheduler.Telerik.WinControls.UI.IPrintable.PrintPage(Int32 pageNumber, RadPrintDocument sender, PrintPageEventArgs args)
       at Telerik.WinControls.UI.RadPrintDocument.OnPrintPage(PrintPageEventArgs e)
       at System.Drawing.Printing.PrintDocument._OnPrintPage(PrintPageEventArgs e)
       at System.Drawing.Printing.PrintController.PrintLoop(PrintDocument document)
       at System.Drawing.Printing.PrintController.Print(PrintDocument document)
       at System.Drawing.Printing.PrintDocument.Print()
       at System.Windows.Forms.PrintPreviewControl.ComputePreview()
       at System.Windows.Forms.PrintPreviewControl.CalculatePageInfo()
       at System.Windows.Forms.Control.InvokeMarshaledCallbackDo(ThreadMethodEntry tme)
       at System.Windows.Forms.Control.InvokeMarshaledCallbackHelper(Object obj)
       at System.Threading.ExecutionContext.runTryCode(Object userData)
       at System.Runtime.CompilerServices.RuntimeHelpers.ExecuteCodeWithGuaranteedCleanup(TryCode code, CleanupCode backoutCode, Object userData)
       at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state)
       at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
       at System.Windows.Forms.Control.InvokeMarshaledCallback(ThreadMethodEntry tme)
       at System.Windows.Forms.Control.InvokeMarshaledCallbacks()


    ************** Loaded Assemblies **************
    mscorlib
        Assembly Version: 2.0.0.0
        Win32 Version: 2.0.50727.5472 (Win7SP1GDR.050727-5400)
        CodeBase: file:///C:/Windows/Microsoft.NET/Framework/v2.0.50727/mscorlib.dll
    ----------------------------------------
    JobPlanner
        Assembly Version: 1.0.0.0
        Win32 Version: 1.0.0.0
        CodeBase: file:///C:/Program%20Files%20(x86)/One/Link/JobPlanner.exe
    ----------------------------------------
    Microsoft.VisualBasic
        Assembly Version: 8.0.0.0
        Win32 Version: 8.0.50727.5420 (Win7SP1.050727-5400)
        CodeBase: file:///C:/Windows/assembly/GAC_MSIL/Microsoft.VisualBasic/8.0.0.0__b03f5f7f11d50a3a/Microsoft.VisualBasic.dll
    ----------------------------------------
    System
        Assembly Version: 2.0.0.0
        Win32 Version: 2.0.50727.5467 (Win7SP1GDR.050727-5400)
        CodeBase: file:///C:/Windows/assembly/GAC_MSIL/System/2.0.0.0__b77a5c561934e089/System.dll
    ----------------------------------------
    System.Windows.Forms
        Assembly Version: 2.0.0.0
        Win32 Version: 2.0.50727.5468 (Win7SP1GDR.050727-5400)
        CodeBase: file:///C:/Windows/assembly/GAC_MSIL/System.Windows.Forms/2.0.0.0__b77a5c561934e089/System.Windows.Forms.dll
    ----------------------------------------
    System.Drawing
        Assembly Version: 2.0.0.0
        Win32 Version: 2.0.50727.5467 (Win7SP1GDR.050727-5400)
        CodeBase: file:///C:/Windows/assembly/GAC_MSIL/System.Drawing/2.0.0.0__b03f5f7f11d50a3a/System.Drawing.dll
    ----------------------------------------
    System.Configuration
        Assembly Version: 2.0.0.0
        Win32 Version: 2.0.50727.5476 (Win7SP1GDR.050727-5400)
        CodeBase: file:///C:/Windows/assembly/GAC_MSIL/System.Configuration/2.0.0.0__b03f5f7f11d50a3a/System.Configuration.dll
    ----------------------------------------
    System.Xml
        Assembly Version: 2.0.0.0
        Win32 Version: 2.0.50727.5476 (Win7SP1GDR.050727-5400)
        CodeBase: file:///C:/Windows/assembly/GAC_MSIL/System.Xml/2.0.0.0__b77a5c561934e089/System.Xml.dll
    ----------------------------------------
    System.Runtime.Remoting
        Assembly Version: 2.0.0.0
        Win32 Version: 2.0.50727.5420 (Win7SP1.050727-5400)
        CodeBase: file:///C:/Windows/assembly/GAC_MSIL/System.Runtime.Remoting/2.0.0.0__b77a5c561934e089/System.Runtime.Remoting.dll
    ----------------------------------------
    Telerik.WinControls.UI
        Assembly Version: 2013.1.777.20
        Win32 Version: 2013.1.777.20
        CodeBase: file:///C:/Program%20Files%20(x86)/One/Link/Telerik.WinControls.UI.DLL
    ----------------------------------------
    Telerik.WinControls
        Assembly Version: 2013.1.777.20
        Win32 Version: 2013.1.777.20
        CodeBase: file:///C:/Program%20Files%20(x86)/One/Link/Telerik.WinControls.DLL
    ----------------------------------------
    Telerik.WinControls.Scheduler
        Assembly Version: 2013.1.777.20
        Win32 Version: 2013.1.777.20
        CodeBase: file:///C:/Program%20Files%20(x86)/One/Link/Telerik.WinControls.Scheduler.DLL
    ----------------------------------------
    System.Data
        Assembly Version: 2.0.0.0
        Win32 Version: 2.0.50727.5420 (Win7SP1.050727-5400)
        CodeBase: file:///C:/Windows/assembly/GAC_32/System.Data/2.0.0.0__b77a5c561934e089/System.Data.dll
    ----------------------------------------
    Telerik.WinControls.GridView
        Assembly Version: 2013.1.777.20
        Win32 Version: 2013.1.777.20
        CodeBase: file:///C:/Program%20Files%20(x86)/One/Link/Telerik.WinControls.GridView.DLL
    ----------------------------------------
    TelerikCommon
        Assembly Version: 2013.1.777.20
        Win32 Version: 2013.1.777.20
        CodeBase: file:///C:/Program%20Files%20(x86)/One/Link/TelerikCommon.DLL
    ----------------------------------------
    7md78np1
        Assembly Version: 2013.1.777.20
        Win32 Version: 2.0.50727.5467 (Win7SP1GDR.050727-5400)
        CodeBase: file:///C:/Windows/assembly/GAC_MSIL/System/2.0.0.0__b77a5c561934e089/System.dll
    ----------------------------------------
    PLFC
        Assembly Version: 1.0.0.0
        Win32 Version: 4.10.20140124.02
        CodeBase: file:///C:/Program%20Files%20(x86)/One/Link/PLFC.DLL
    ----------------------------------------
    System.Transactions
        Assembly Version: 2.0.0.0
        Win32 Version: 2.0.50727.4927 (NetFXspW7.050727-4900)
        CodeBase: file:///C:/Windows/assembly/GAC_32/System.Transactions/2.0.0.0__b77a5c561934e089/System.Transactions.dll
    ----------------------------------------
    System.EnterpriseServices
        Assembly Version: 2.0.0.0
        Win32 Version: 2.0.50727.5420 (Win7SP1.050727-5400)
        CodeBase: file:///C:/Windows/assembly/GAC_32/System.EnterpriseServices/2.0.0.0__b03f5f7f11d50a3a/System.EnterpriseServices.dll
    ----------------------------------------
    System.Web
        Assembly Version: 2.0.0.0
        Win32 Version: 2.0.50727.5474 (Win7SP1GDR.050727-5400)
        CodeBase: file:///C:/Windows/assembly/GAC_32/System.Web/2.0.0.0__b03f5f7f11d50a3a/System.Web.dll
    ----------------------------------------




  2. Stefan
    Admin
    Stefan avatar
    2891 posts

    Posted 31 Jan 2014 Link to this post

    Hello Richard,

    Thank you for writing.

    I can confirm that two page printing in grouped by resource mode is not supported in weekly style and I have logged this case in our feedback portal. You can add your vote and subscribe for status notifications here: http://feedback.telerik.com/Project/154/Feedback/Details/114256-fix-radscheduler-argumentoutofrangeexception-is-thrown-when-attempting-to-prin

    I have updated your Telerik Points for this report. 

    Meanwhile, you can modify the print dialog to disallow selecting this option to the user. Here is how this can be done:
    protected override void OnLoad(EventArgs e)
    {
        base.OnLoad(e);
        AddScheduler();
     
        radScheduler1.PrintSettingsDialogFactory = new MyFactory();
    }
     
    private void radButton1_Click(object sender, EventArgs e)
    {
        radScheduler1.PrintPreview();
    }
     
    class MySchedulerPrintSettingsDialogFactory : SchedulerPrintSettingsDialog
    {
        SchedulerPrintStyleSettings userControl;
        RadDropDownList groupBy;
        RadDropDownList twoPagesPerView;
        RadDropDownList printStyle;
     
        public MySchedulerPrintSettingsDialogFactory(RadPrintDocument document)
            : base(document)  { }
     
        protected override Control CreateFormatControl()
        {
            userControl = base.CreateFormatControl() as SchedulerPrintStyleSettings;
            RadGroupBox groupBox = userControl.Controls["groupBoxStyleSettings"] as RadGroupBox;
     
            groupBy = groupBox.Controls["dropDownGroupBy"] as RadDropDownList;
            groupBy.SelectedIndexChanged += groupBy_SelectedIndexChanged;
     
            twoPagesPerView = groupBox.Controls["dropDownLayout"] as RadDropDownList;
            twoPagesPerView.SelectedIndexChanging += twoPagesPerView_SelectedIndexChanging;
     
            RadGroupBox groupBoxMain = userControl.Controls["groupBoxPrintStyle"] as RadGroupBox;
            printStyle = groupBoxMain.Controls["dropDownPrintStyle"] as RadDropDownList;
            printStyle.SelectedValueChanged += printStyle_SelectedValueChanged;
            return userControl;
        }
     
        void printStyle_SelectedValueChanged(object sender, EventArgs e)
        {
            if (printStyle.SelectedItem.Text == "Weekly Style")
            {
                twoPagesPerView.SelectedItem = twoPagesPerView.Items[0];
            }
        }
     
        void twoPagesPerView_SelectedIndexChanging(object sender, Telerik.WinControls.UI.Data.PositionChangingCancelEventArgs e)
        {
            if (groupBy.SelectedItem.Text == "Resource" && e.Position == 1)
            {
                e.Cancel = true;
                RadMessageBox.Show("Two pages per view is not supported in GroupBy:Resource mode");
            }
        }
     
        void groupBy_SelectedIndexChanged(object sender, Telerik.WinControls.UI.Data.PositionChangedEventArgs e)
        {
            if (groupBy.Items[e.Position].Text == "Resource")
            {
                twoPagesPerView.SelectedItem = twoPagesPerView.Items[0];
            }
        }
    }
     
    class MyFactory : IPrintSettingsDialogFactory
    {
        public Form CreateDialog(RadPrintDocument document)
        {
            return new MySchedulerPrintSettingsDialogFactory(document);
        }
    }

    I hope that you find this information useful. Should you have any other questions or suggestions, do not hesitate to contact us.

    Regards,
    Stefan
    Telerik
    TRY TELERIK'S NEWEST PRODUCT - APPLICATION ANALYTICS for WINFORMS.
    Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
    Sign up for Free application insights >>
  3. UI for WinForms is Visual Studio 2017 Ready
  4. Richard
    Richard avatar
    32 posts
    Member since:
    Aug 2010

    Posted 09 Feb 2014 in reply to Stefan Link to this post

    Hi Stefan, 

    Thanks for providing me the fix, but PrintSettingsDialogFactory property is not available with my version. I am using 2013-1-220 build.  I think this is introduced in 2013.3.1328.40 version. We have not yet decided to upgrade the latest one. Is there any other work around for this?

    In your post, you have mentioned that my telerik points were updated, but I could not find the same. Could you please check. 

    Regards
    Richard.

  5. Stefan
    Admin
    Stefan avatar
    2891 posts

    Posted 10 Feb 2014 Link to this post

    Hello Richard,

    The property mentioned was introduced in Q1 2013 SP1 - the very next release after the one you use. Unfortunately, with your version there is no way to use this factory. What you can do is to avoid using these methods of RadScheduler and instead create your own RadPrintDocument, associate it with RadScheduler and pass this document to a dialog of your own to use. This way you will control the printing via this document. 

    I hope this helps.

    Regards,
    Stefan
    Telerik

    Check out the new Telerik Platform - the only modular platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native apps. Register for the free online keynote and webinar to learn more about the Platform on Wednesday, February 12, 2014 at 11:00 a.m. ET (8:00 a.m. PT).

Back to Top