How to Set a Ribbonbars tab selected?

4 posts, 1 answers
  1. Deasun
    Deasun avatar
    13 posts
    Member since:
    Jan 2017

    Posted 10 Aug 2018 Link to this post

    Morning,

    Anyone know how to do this?

    I tried: rbTBMgr.CommandTabs["Tools"].Select()

    Commandtabs dont seem to have a .IsSelect().

    All I want to do is make a tab selected!

    Frustrated infragistics user!

  2. Dess | Tech Support Engineer, Sr.
    Admin
    Dess | Tech Support Engineer, Sr.  avatar
    3466 posts

    Posted 10 Aug 2018 Link to this post

    Hello, Deasun,      

    In order to select a certain tab, you an directly set the RibbonTab.IsSelected property to true in the Load event. Thus, the desired tab will be selected. I have attached a sample project for your reference.

    I hope this information helps. If you have any additional questions, please let me know.  
     
    Regards,
    Dess
    Progress Telerik
    Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
  3. Deasun
    Deasun avatar
    13 posts
    Member since:
    Jan 2017

    Posted 10 Aug 2018 in reply to Dess | Tech Support Engineer, Sr. Link to this post

    Thanks for the reply.

    What I was trying to do was stop the user from switching to another tab while they were editing data.

    I was hoping to do something in the _CommandTabSelected event.
    Like: If Mode = EDIT then CommandTab.Selected = Commandtab.Previoustab

    But I dont see any property like that.
    After reading some forums it seems I have to keep track of previoustab myself.

    After doing that I tried to set the tab back to the tab their editing on.
    Something like: rbTBMgr.Commandtab["Tools"].selected = true
    Couldnt find anything close to that. Ended up with this:
    rbTBMgr.RibbonBarElement.TabStripElement.SelectedItem = rbTBMgr.RibbonBarElement.TabStripElement.Items[1];

    But I have to keep track of the index now. I couldnt find a way to reference the tab by name.
    Something like:
    rbTBMgr.RibbonBarElement.TabStripElement.SelectedItem = rbTBMgr.RibbonBarElement.TabStripElement.Items["Tools"];

    Is there no simplier why to do this?

    Thanks
    Deasun
  4. Answer
    Dess | Tech Support Engineer, Sr.
    Admin
    Dess | Tech Support Engineer, Sr.  avatar
    3466 posts

    Posted 13 Aug 2018 Link to this post

    Hello, Deasun,      

    If you need to block the user from switching to another tab, you can simply handle the RadRibbonBar.CommandTabSelecting event and set the CommandTabSelectingEventArgs.Cancel property to true. In the event args you have access to the new and previous tab so you can check the Text for example: 

    private void radRibbonBar1_CommandTabSelecting(object sender, CommandTabSelectingEventArgs args)
    {
        if (args.NewCommandTab.Text.Contains("D"))
        {
            args.Cancel = true;
        }
    }

    I hope this information helps. If you have any additional questions, please let me know.  
     
    Regards,
    Dess
    Progress Telerik
    Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
Back to Top