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

Set toobtab active on document select

3 Answers 220 Views
Dock
This is a migrated thread and some comments may be shown as answers.
Denis Cilliers
Top achievements
Rank 1
Denis Cilliers asked on 18 Sep 2012, 08:56 AM
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



3 Answers, 1 is accepted

Sort by
0
Nikolay
Telerik team
answered on 19 Sep 2012, 03:46 PM
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 >>
0
Denis Cilliers
Top achievements
Rank 1
answered on 20 Sep 2012, 11:23 AM
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
0
Nikolay
Telerik team
answered on 20 Sep 2012, 01:27 PM
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 >>
Tags
Dock
Asked by
Denis Cilliers
Top achievements
Rank 1
Answers by
Nikolay
Telerik team
Denis Cilliers
Top achievements
Rank 1
Share this question
or