Print Preview Key Press Event

2 posts, 0 answers
  1. Saif
    Saif  avatar
    30 posts
    Member since:
    Apr 2014

    Posted 22 Jun 2014 Link to this post

    Hi, 

    I want to know how to apply the key press on print preview style of the scheduler.
    If user press arrow up/down it will go to next/previous page.

    Thanks.
  2. Stefan
    Admin
    Stefan avatar
    2890 posts

    Posted 23 Jun 2014 Link to this post

    Hello Saif,

    Thank you for writing.

    Here is how you can extend the print preview dialog in order to achieve your requirement: 
    RadPrintDocument document = new RadPrintDocument();
     
     private void radButton1_Click(object sender, EventArgs e)
     {
         document.AssociatedObject = radScheduler1;
     
         MyRadPrintPreviewDialog dialog = new MyRadPrintPreviewDialog();
         dialog.Document = document;
         dialog.ShowDialog();
     }
     
     class MyRadPrintPreviewDialog : RadPrintPreviewDialog
     {
         protected override void OnLoad(EventArgs e)
         {
             base.OnLoad(e);
     
             CommandBarTextBox txtBox = this.ToolCommandBar.Rows[0].Strips[1].Items[2] as CommandBarTextBox;
             txtBox.KeyDown += txtBox_KeyDown;
         }
     
         void txtBox_KeyDown(object sender, KeyEventArgs e)
         {
             if (e.KeyCode == Keys.Down)
             {
                 if (this.printPreviewControl.StartPage < this.Document.PageCount)
                 {
                     this.printPreviewControl.StartPage++;
                 }
             }
             else if (e.KeyCode == Keys.Up)
             {
                 if (this.printPreviewControl.StartPage > 0)
                 {
                     this.printPreviewControl.StartPage--;
                 }
             }
         }
     }

    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
     
    Check out Telerik Analytics, the service which allows developers to discover app usage patterns, analyze user data, log exceptions, solve problems and profile application performance at run time. Watch the videos and start improving your app based on facts, not hunches.
     
  3. UI for WinForms is Visual Studio 2017 Ready
Back to Top