This is a migrated thread and some comments may be shown as answers.
Selecting Tabs via code
17 Answers 233 Views
This is a migrated thread and some comments may be shown as answers.
dennis_dieckmann
Top achievements
Rank 1
dennis_dieckmann asked on 06 May 2007, 11:12 AM
Hi,

mabe I'm to dumb, but I haven't figured out how I can select a tab with code.

In the Tabcontrol object from VS05 it's working like this: TabControl1.SelectTab(TabPage2)

How can I realize this with the Ribbonbar?

Thanks for your help.

Dennis

17 Answers, 1 is accepted

Sort by
0
surfer
Top achievements
Rank 1
answered on 06 May 2007, 02:27 PM
You can use the TabStripElement.SelectedTab property of the RibbonBarElement, for example using the code below you can select the second tab (collection is zero based)

e.g.

// C#
radRibbonBar1.RibbonBarElement.TabStripElement.SelectedTab = radRibbonBar1.RibbonBarElement.TabStripElement.Items[1];

' VB.NET
radRibbonBar1.RibbonBarElement.TabStripElement.SelectedTab = radRibbonBar1.RibbonBarElement.TabStripElement.Items(1)
0
Boyko Markov
Telerik team
answered on 07 May 2007, 08:50 AM
Hello Matt Stewart,

Indeed this works fine but it would be a good idea to check whether the index of the tab is  not out of range of the items collection boundaries.

e.g.
int index = 1; 
if (( radRibbonBar1.RibbonBarElement.TabStripElement.Items.Count < index ) &&  
(index >=0 )) 
radRibbonBar1.RibbonBarElement.TabStripElement.SelectedTab = radRibbonBar1.RibbonBarElement.TabStripElement.Items[1]; 



Regards,
Ray
the telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
surfer
Top achievements
Rank 1
answered on 07 May 2007, 08:54 AM
Sure. This was just to serve the example. Bounds checking is always a good idea. And in your code the check should be reverse:

e.g.

instead of
radRibbonBar1.RibbonBarElement.TabStripElement.Items.Count < index

this one
index < radRibbonBar1.RibbonBarElement.TabStripElement.Items.Count
0
Boyko Markov
Telerik team
answered on 07 May 2007, 10:59 AM
Hello Matt Stewart,
I confirm that the index should be smaller than the count of the items in the collection.
Thank you for the correction.

Best wishes,
Ray
the telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
dennis_dieckmann
Top achievements
Rank 1
answered on 07 May 2007, 12:46 PM
Hi,

thank you. This is working fine...

By the way:
There is a graphical bug when I do this!

When you click the tab on the ribbonbar, than everything is ok.
But if you select a tab with this code, than you have a line under the tab.

Please have a look on this picture:
http://dennisdieckmann.de.funpic.de/ribbonbar.png

I'm using Q4 2006 release.
0
Boyko Markov
Telerik team
answered on 07 May 2007, 02:30 PM
Hi dennis_dieckmann,

We will investigate the problem which you have reported.
I suggest that you download the  Q1 release of RadControls for WinForms because the line below the TabStrip could have been a bug which is already fixed.
Thank you for the valuable feedback.


All the best,
Ray
the telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
Kevin
Top achievements
Rank 1
answered on 07 May 2007, 04:08 PM
Maybe you can try suspending the Form Layout until the changes are made? This is similar to what telerik serialization code does in the Form.Designer.cs files, so it may work around the redrawing issue:

            this.SuspendLayout(); 
            radRibbonBar1.RibbonBarElement.TabStripElement.SelectedTab = radRibbonBar1.RibbonBarElement.TabStripElement.Items[1]; 
            this.ResumeLayout(false); 

0
dennis_dieckmann
Top achievements
Rank 1
answered on 07 May 2007, 04:20 PM
Isn't working in my Project.

Whatever.. this line isn't that much important to me.
0
lprada
Top achievements
Rank 2
answered on 07 May 2007, 05:23 PM
It will be great if you cant select the tab by name or Key. Because if you canhe orders the code is broke.

Thanks
0
Boyko Markov
Telerik team
answered on 08 May 2007, 09:24 AM
Hi Leonardo Prada,

We agree with you that it would be a nice feature to select a tab by name and we will add it to our To Do list for the scheduled SP2 release.
If you have any other interesting ideas about adding new features and functionality to our controls please do not hesitate to share them with us.

Best wishes,
Ray
the telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
DukeVideo
Top achievements
Rank 1
answered on 14 Jun 2007, 10:09 AM
What if the tab is in a contextual group?

I can display the contextual tab group, but how do I auto-select it?

if (sender is ProdMasterTab) 
            { 
 
                // hide all tab groups 
                foreach (ContextualTabGroup contextualTabGroup in RadRibbonBar.ContextualTabGroups) 
                { 
                    contextualTabGroup.Visibility=ElementVisibility.Collapsed; 
                } 
 
                foreach (ContextualTabGroup contextualTabGroup in RadRibbonBar.ContextualTabGroups) 
                { 
                    if ((string)contextualTabGroup.Tag=="ProdMaster"
                    { 
                        contextualTabGroup.Visibility=ElementVisibility.Visible; 
 
                         
                             
                            //TabStripElement.SelectedTab =                this.radRibbonBar1.RibbonBarElement.TabStripElement.Items[0]; 
 
                        //contextualTabGroup. 
                        //RadRibbonBar.SelectedCommandTab=contextualTabGroup.TabItems[0];// =contextualTabGroup.TabItems[0]; 
                    } 
                } 
            } 

0
Jordan
Telerik team
answered on 14 Jun 2007, 11:51 AM
Hi Dennis,

If I understand you correctly, you want to "activate" the contextual group as if it was clicked. The contextual groups in RadRibbonBar do not support this functionality. However when a contextual tab group is clicked the first tab in it will get selected.

Hope that helps.
 

Best wishes,
Jordan
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
DukeVideo
Top achievements
Rank 1
answered on 15 Jun 2007, 08:15 AM
Why do they not support that functionality? Seems obvious to me.

It also happens in Office 2007, so if you were mimicking the Office UI, then why not mimick this feature?
0
Jordan
Telerik team
answered on 15 Jun 2007, 02:17 PM
Hello Dennis,

The RadRibbonBar was designed as per the early drafts of the Office 2007 UI guidelines from Microsoft - this is reason why this difference exists. We are considering some improvements in RadRibbonBar, including the one discussed here, but we cannot give you a specific timeframe at the moment.

As for the auto activate feature of contextual tab groups - thank you for pointing this out. We have added it in our TODO list for the Q2 2007 release.
 

Greetings,
Jordan
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
DukeVideo
Top achievements
Rank 1
answered on 30 Oct 2007, 08:29 AM
Hi,

Has this auto activate of Contextual Groups been added yet? I'm keen to use it to help my users out with their/my usability issues.
0
Jordan
Telerik team
answered on 31 Oct 2007, 08:33 AM
Hello DukeVideo,

Unfortunately, this feature was dropped from the 2007 Q2 release because of some other high priority tasks.
This feature is still on our TODO list and will be implemented as soon as possible, but we cannot give a specific timeframe at the moment.

Contact us again if you have additional questions.

Greetings,
Jordan
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
KMBah
Top achievements
Rank 1
answered on 25 Feb 2008, 09:16 PM
For those that wanted to select tabs by name (like I needed to), here is some code. It's simple, but it works.

foreach (RadItem ri in radRibbonBar1.RibbonBarElement.TabStripElement.Items)  
{  
    if (ri.Text == "TabTextValue")  
    {  
        radRibbonBar1.RibbonBarElement.TabStripElement.SelectedTab = ri;  
        break;  
    }  
Asked by
dennis_dieckmann
Top achievements
Rank 1
Answers by
surfer
Top achievements
Rank 1
Boyko Markov
Telerik team
dennis_dieckmann
Top achievements
Rank 1
Kevin
Top achievements
Rank 1
lprada
Top achievements
Rank 2
DukeVideo
Top achievements
Rank 1
Jordan
Telerik team
KMBah
Top achievements
Rank 1
Share this question
or