This is a migrated thread and some comments may be shown as answers.

How to Set a Ribbonbars tab selected?

3 Answers 71 Views
RibbonBar
This is a migrated thread and some comments may be shown as answers.
Deasun
Top achievements
Rank 1
Deasun asked on 10 Aug 2018, 12:58 PM

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!

3 Answers, 1 is accepted

Sort by
0
Dess | Tech Support Engineer, Principal
Telerik team
answered on 10 Aug 2018, 01:30 PM
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.
0
Deasun
Top achievements
Rank 1
answered on 10 Aug 2018, 01:49 PM
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
0
Accepted
Dess | Tech Support Engineer, Principal
Telerik team
answered on 13 Aug 2018, 10:24 AM
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.
Tags
RibbonBar
Asked by
Deasun
Top achievements
Rank 1
Answers by
Dess | Tech Support Engineer, Principal
Telerik team
Deasun
Top achievements
Rank 1
Share this question
or