Set toobtab active on document select

4 posts, 0 answers
  1. Denis Cilliers
    Denis Cilliers avatar
    62 posts
    Member since:
    Jan 2004

    Posted 18 Sep 2012 Link to this post

    How do you set a tooltab active when selecting a document

    I have two tool tabs with different details on them, and wanted to set one or the other active when I add a document to the document tab section

    Private Sub radDockMain_ActiveWindowChanged(ByVal sender As Object, ByVal e As Telerik.WinControls.UI.Docking.DockWindowEventArgs) Handles radDockMain.ActiveWindowChanged
           'This event fires when a document tab is changed
           Select Case e.DockWindow.Text
               Case "Schedule"
                   MessageBox.Show("Schedule Selected")
                   twSideMenu.Show()
               Case "Details"
                   MessageBox.Show("Details Selected")
                   'Show the Shedule tool strip
                   twDetails.Show()
               Case "Today"
                   MessageBox.Show("Today Selected")
               Case "Details"
                   MessageBox.Show("Details Selected")
           End Select
       End Sub

    Any idea how to make the tab show as currently there is no difference as I select the document the event fires, but nothing changes on the tooltabs



  2. Nikolay
    Admin
    Nikolay avatar
    1803 posts

    Posted 19 Sep 2012 Link to this post

    Hello Denis,

    Selecting a window in the ActiveWindowChanged event is not permitted by design. Still, there is a way to achieve what you are after. With a bit of Reflection you can enable the selection the following way:

    Partial Public Class Form1
        Inherits Form
        Private fInfo As FieldInfo
     
        Public Sub New()
            InitializeComponent()
     
            AddHandler radDock1.ActiveWindowChanged, AddressOf radDock1_ActiveWindowChanged
     
            fInfo = GetType(RadDock).GetField("settingActiveWindow", BindingFlags.NonPublic Or BindingFlags.Instance)
        End Sub
     
        Private Sub radDock1_ActiveWindowChanged(ByVal sender As Object, ByVal e As Telerik.WinControls.UI.Docking.DockWindowEventArgs)
            Dim docText As String = e.DockWindow.Text
            Select Case docText
                Case "documentWindow1"
                    fInfo.SetValue(Me.radDock1, False)
                    Me.radDock1.ActiveWindow = Me.toolWindow1
                    fInfo.SetValue(Me.radDock1, True)
                Case "documentWindow2"
                    fInfo.SetValue(Me.radDock1, False)
                    Me.radDock1.ActiveWindow = Me.toolWindow2
                    fInfo.SetValue(Me.radDock1, False)
                Case "documentWindow3"
                    fInfo.SetValue(Me.radDock1, False)
                    Me.radDock1.ActiveWindow = Me.toolWindow3
                    fInfo.SetValue(Me.radDock1, True)
            End Select
        End Sub
    End Class

    In short, you should change the value of a private field named settingActiveWindow to allow the explicit selection.

    I hope this helps.

    Kind regards,
    Nikolay
    the Telerik team
    RadControls for WinForms Q2'12 release is now live! Check out what's new or download a free trial >>
  3. UI for WinForms is Visual Studio 2017 Ready
  4. Denis Cilliers
    Denis Cilliers avatar
    62 posts
    Member since:
    Jan 2004

    Posted 20 Sep 2012 Link to this post

    Hi Nikolay

    I found that if I just hide or show the tabs it works great my code is currently just

    Select Case e.DockWindow.Text
      
                Case "Schedule"
                    'MessageBox.Show("Schedule Selected")
      
                    twSideMenu.Show()
                    twDetails.Hide()
    etc...

    Why would there be a restriction on selecting the window in ActiveWindowChanged ?
    When this works
  5. Nikolay
    Admin
    Nikolay avatar
    1803 posts

    Posted 20 Sep 2012 Link to this post

    Hello Denis,

    I am glad to hear that you have found an approach that works for you.

    Selecting a window in the ActiveWindowChanged event is prohibited, because of the complex selection mechanism of RadDock that should be safe when a selection in RadDock is processed. There are certain cases like yours where there should be no issues with explicit selection in the event, but in general such actions are not recommended and we do not plan to allow that selection in future.

    I hope that this makes sense.

    Greetings,
    Nikolay
    the Telerik team
    RadControls for WinForms Q2'12 release is now live! Check out what's new or download a free trial >>
Back to Top