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

Changing currently selected tab programatically

6 Answers 386 Views
RibbonBar
This is a migrated thread and some comments may be shown as answers.
Jack
Top achievements
Rank 1
Jack asked on 24 Feb 2011, 11:12 PM
Hello -

I thought this would be easy enough, and am still sure it must be, but .....

Can anyone post a snippet of:

1) How I would change the currently selected tab in a radribbonbar programatically?
2) Tell me which event gets fired when the selected tab changes?

My situation is that I have a standard windows tab control nested under the radribbonbar control. When the user changes the selected tab on the radribbonbar, I need to change the selected tab on the standard windows tab control as well.

Thanks much -
Jack

6 Answers, 1 is accepted

Sort by
0
Richard Slade
Top achievements
Rank 2
answered on 25 Feb 2011, 11:09 PM
Hello Jack,

this should answer both your questions. It shows how to select a tab, and also registering an event handler to show when the tab has changed.
Private Sub RadRibbonForm1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    AddHandler Me.RibbonTab1.PropertyChanged, AddressOf RibbonTab1_PropertyChanged
    Me.RibbonTab1.IsSelected = True
End Sub
Private Sub RibbonTab1_PropertyChanged(ByVal sender As Object, ByVal e As PropertyChangedEventArgs)
    If e.PropertyName = "IsSelected" Then
        MessageBox.Show("RibbonTab1 Selected")
    End If
End Sub


Let me know if you have any questions
Richard
0
Richard Slade
Top achievements
Rank 2
answered on 28 Feb 2011, 12:23 PM
Hello,

If you found this helpful, please remember to mark as answer. If you need further assistance, please let me know
Thanks
Richard
0
Jack
Top achievements
Rank 1
answered on 28 Feb 2011, 02:11 PM
Richard -

This doesn't seem to work; (maybe I lost something in the VB to C# conversion)

public Form1() 
      InitializeComponent(); 
      this.radRibbonBar1.PropertyChanged += new PropertyChangedEventHandler(radRibbonBar1_PropertyChanged);  
      this.ribbonTab1.IsSelected = true;
  
private void radRibbonBar1_PropertyChanged(object sender, EventArgs e) 
            // Never fires 
}


However, the following event does fire, which achieves my goal:

 
private void radRibbonBar1_CommandTabSelected(object sender, Telerik.WinControls.UI.CommandTabEventArgs args)
{            
    if (args.CommandTab.Text == "foo1")
    {
    }            
}

 

 

But I'm left wondering ..

Did I miss something in the translation, or is the CommandTabSelected event the one I should trap?

Thanks
Jack



0
Accepted
Richard Slade
Top achievements
Rank 2
answered on 28 Feb 2011, 02:17 PM
Hi Jack,

Yes, the problem in your code was that you were handling the event for the RadRibonBar, not the RibbonTab. The event is for each RibbonTab that you have in your RadRibbonBar, but I'm glad you have another solution which seems also to be fine.
regards,
Richard
0
Jack
Top achievements
Rank 1
answered on 28 Feb 2011, 02:34 PM
Thanks Richard,

I went back and tested and your original solution works as well... sorry, havn't had my morning pot of coffee yet.

Thanks
Jack
0
Richard Slade
Top achievements
Rank 2
answered on 28 Feb 2011, 02:48 PM
We all need our morning coffee Jack. Glad it helped. Your solution is fine too.
Thanks
Richard
Tags
RibbonBar
Asked by
Jack
Top achievements
Rank 1
Answers by
Richard Slade
Top achievements
Rank 2
Jack
Top achievements
Rank 1
Share this question
or