BackStage View Show By Code

12 posts, 0 answers
  1. M_M
    M_M avatar
    3 posts
    Member since:
    Jan 2010

    Posted 08 May 2011 Link to this post

    how can i activate (show) a specific tab in backstage view using code just by code ? (like when u press ctrl+p in microsoft word, it brings up "Print Preview Backstage")
  2. Ivan Todorov
    Admin
    Ivan Todorov avatar
    688 posts

    Posted 10 May 2011 Link to this post

    Hi vbearn vb,

    There are two approaches to achieve this. The first one is by using our shortcut mechanism:
    this.backstageTabPrintPreview.Shortcuts.Add(new RadShortcut(Keys.Control, Keys.P));

    This will simulate a click on the item whenever you press Control + P keys.

    The second approach concerns the usage of RadRibbonBarBackstageView's SelectedItem property:
    this.myBackstageView.SelectedItem = this.backstageTabPrintPreview;

    I hope you find this helpful. Feel free to contact me if you have any additional questions.

    Greetings,
    Ivan Todorov
    the Telerik team
    Q1’11 SP1 of RadControls for WinForms is available for download; also available is the Q2'11 Roadmap for Telerik Windows Forms controls.
  3. UI for WinForms is Visual Studio 2017 Ready
  4. M_M
    M_M avatar
    3 posts
    Member since:
    Jan 2010

    Posted 15 May 2011 Link to this post

    thanks for ur reply admin.
    due to restrictions in my app, i cant use first approach, because most of the times Backstage must be triggered in source code (e.g. in click event of a button). i like something like second approach, but just setting SelectedItem of backstage will not bring up backstageview. actually nothing happens when i just set SelectedItem = ... (consider that the backstage had not been opened yet, i want to open backstage first, and then select my appropriate tab)

    i used a block of code like this for my purpose:

    frmMain.Instance.RibbonBar.BackstageControl.SelectedItem = frmMain.Instance.backstageTabReport;
    frmMain.Instance.RibbonBar.BackstageControl.ShowPopup(
        new System.Drawing.Point(2, 35), frmMain.Instance.RibbonBar.RibbonBarElement);

       and backstage showed. but sometimes backstage is shown and simply not any tab is selected (it is just an empty white screen) so i added this after my last code:

    frmMain.Instance.RibbonBar.BackstageControl.BackstageElement.SuspendLayout();
    frmMain.Instance.RibbonBar.BackstageControl.BackstageElement.ResumeLayout(true, true);

    it seems to work out ok. i just needed to know if there is any other convenient way to do this? my solution doesnt seem bugproof.
  5. Ivan Todorov
    Admin
    Ivan Todorov avatar
    688 posts

    Posted 18 May 2011 Link to this post

    Hello M_M,

    I was not able to reproduce the described issue. There might be something specific in your project that is causing it. However, I would suggest you to set the selected item after you have shown the backstage. Please let me know if this works. If not, I would kindly ask you to post here a code sample that reproduces the issue. This will help me to locate the issue and provide you with accurate support.

    I am looking forward to your reply.

    Greetings,
    Ivan Todorov
    the Telerik team
    Q1’11 SP1 of RadControls for WinForms is available for download; also available is the Q2'11 Roadmap for Telerik Windows Forms controls.
  6. Markus
    Markus avatar
    1 posts
    Member since:
    Oct 2011

    Posted 02 Nov 2011 Link to this post

    HI there,

    same issue over here: How do I programmatically show the Backstage View?
    Setting the selected item does not do anything. Using M_M's solution leads to layout errors on the ribbon bar...

    Greetings,

    Markus
  7. Ivan Todorov
    Admin
    Ivan Todorov avatar
    688 posts

    Posted 03 Nov 2011 Link to this post

    Hi Markus,

    M_M's solution uses the same code that is internally used to show the backstage view, so there should not be any issues with it. Please describe what kind of errors you are experiencing. You can also post the code you are using, so I can test it and reproduce them. This will let me provide you with more accurate answers.

    I am looking forward to your reply.

    Greetings,
    Ivan Todorov
    the Telerik team

    Q2’11 SP1 of RadControls for WinForms is available for download (see what's new); also available is the Q3'11 Roadmap for Telerik Windows Forms controls.

  8. Drakemar
    Drakemar avatar
    3 posts
    Member since:
    Dec 2011

    Posted 21 Dec 2011 Link to this post

    Hello,

    I'm facing the same issue.  I've created a RadRibbonForm with ApplicationMenuStyle = BackstageView.  When I start the application the BackstageView does not appear, and I have to click the tab in the top left to activate it.

    I've been able to get it to show, sometimes, by programmatically setting the BackstageTabItem.  However, it no longer seems to work.  Additionally, this was working, the BackstageView would not be expanded and caused a layout issue.  Clicking on the tab would resolve the layout, but this is not desired.

    Therefore, what I want to achieve is to have the BackstageView open on runtime, autosized, and have the tab highlighted.  However, I cannot manage to find a way to do this.

    A couple other notes:
    1. The events for BackstageViewOpened and Opening don't seem to work at all.
    2. Is it possible to show the nice round graphical image in the TopLeft in BackstageView mode?

    Thank you.


  9. Ivan Todorov
    Admin
    Ivan Todorov avatar
    688 posts

    Posted 23 Dec 2011 Link to this post

    Hello,

    There really seems to be some issues in this scenario with BackstageView since there are already three people who have complained about it. However, we are still not able to reproduce them and none of the people who wrote in this thread have sent a sample which demonstrates the issues. We will be grateful if you can demonstrate your scenario in a sample project. This will let us investigate it and provide you with adequate support. Please note that you have to open a new support ticket from Your Account in order to be able to attach files.

    As to your additional questions, I have tested the BackstageViewOpening / Opened events and they seem to fire properly in all cases. As to changing the style of the corner button, here is how you can achieve this:
    public Form1()
    {
        InitializeComponent();
        this.radRibbonBar1.RibbonBarElement.SetValue(RadRibbonBarElement.IsBackstageModeProperty, false);         
        this.radRibbonBar1.RibbonBarElement.ApplicationButtonElement.SetValue(RadRibbonBarElement.IsBackstageModeProperty, false);
        this.radRibbonBar1.RibbonBarElement.QuickAccessToolBar.SetValue(RadRibbonBarElement.IsBackstageModeProperty, false);
        RadQuickAccessToolBar.InnerItem item = this.radRibbonBar1.RibbonBarElement.QuickAccessToolBar.GetInnerItem();
        if (item != null)
            item.SetValue(RadRibbonBarElement.IsBackstageModeProperty, false);
    }

    I hope this will help you. I am looking forward to hearing from you.

    All the best,
    Ivan Todorov
    the Telerik team

    Q3’11
    of RadControls for WinForms is available for download (see what's new). Get it today.
  10. Drakemar
    Drakemar avatar
    3 posts
    Member since:
    Dec 2011

    Posted 23 Dec 2011 Link to this post

    Thank you for the reply, Ivan. The code to make the rounded button works very nicely.

    The events for opening closing are unrelated to the controls themselves, it was a source control issue. So, you can safely ignore these as issues.

    Finally, at your request I opened a ticket for this issue (#495839)  in which I've added a sample project. 


    Sincerely,

    Mark
  11. Ivan Todorov
    Admin
    Ivan Todorov avatar
    688 posts

    Posted 28 Dec 2011 Link to this post

    Hello Drakemar,

    Thank you for opening a support ticket and providing us with a sample project. You can check my reply in that support ticket.

    I will post some updates on this case here, so the community can benefit from it too:

    By design, the BackstageView should be opened only when the form has been displayed. Therefore, opening the BackstageView programatically in the form's constructor will result in an incorrect layout. To overcome this, you should show the BackstageView in the form's OnShow event. Additionally, there seems to be an issue with RadRibbonForm and BackstageView when the form is maximized. This issue is logged in PITS and can be found at this link. To workaround it, you need to handle the SizeChanged event of the form and recalculate the proper position of the BackstageView. The following code snippet demonstrates this:

    public Form1()
    {
        InitializeComponent();
        this.SizeChanged += new System.EventHandler(MainForm_SizeChanged);
    }
      
    public Point GetBackstageLocation()
    {
        Point location = radRibbonBar1.RibbonBarElement.ApplicationButtonElement.ControlBoundingRectangle.Location;
        location.Offset(new Point(0, radRibbonBar1.RibbonBarElement.ApplicationButtonElement.ControlBoundingRectangle.Height));
        location.Offset(radRibbonBar1.Location);
      
        return location;
    }
      
    void MainForm_SizeChanged(object sender, System.EventArgs e)
    {
        if (radRibbonBar1.BackstageControl != null && radRibbonBar1.BackstageControl.IsShown)
        {
            radRibbonBar1.BackstageControl.Location = GetBackstageLocation();
        }
    }
      
    protected override void OnShown(System.EventArgs e)
    {
        base.OnShown(e);
        radRibbonBar1.BackstageControl.ShowPopup(GetBackstageLocation(), radRibbonBar1.RibbonBarElement);
    }

    I hope this will help you. In case you have any further questions, do not hesitate to write back.

    Regards,
    Ivan Todorov
    the Telerik teamQ3’11 of RadControls for WinForms is available for download (see what's new). Get it today.
  12. Drakemar
    Drakemar avatar
    3 posts
    Member since:
    Dec 2011

    Posted 28 Dec 2011 Link to this post

    Thank you very much for the support.  The code presented does the job :)

    Sincerely,

    Mark
  13. Stefan
    Admin
    Stefan avatar
    2891 posts

    Posted 28 Dec 2011 Link to this post

    Hi,

    I am glad we could help. Should you have any other questions, do not hesitate to contact us.

    Regards,
    the Telerik team
Back to Top
UI for WinForms is Visual Studio 2017 Ready