Problem with visible/invisible ToolWindow in RadDock with SaveLayout

3 posts, 1 answers
  1. Franco
    Franco avatar
    27 posts
    Member since:
    Apr 2010

    Posted 13 Jan 2011 Link to this post

    Good morning.
    I have found something strange in the behavior of your RadDock control. I create a simple test project: a Windows Form Application with one RadMenu and one RadDock. In the RadDock I add a new ToolWindow to the left, in the RadMenu I add only one MenuItem. Here's the code (Visual Basic Express 2008 in a Windows XP SP3 environment, Telerik RadControls WinForms Q3 2010):
    Imports Telerik.WinControls.UI.Docking
      
    Public Class Form1
      Private file As String = "a.xml"
      
      Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        Me.Visible = False
      
        If (System.IO.File.Exists(file)) Then RadDock1.LoadFromXml(file)
        RadDock1.Visible = False
      
        Me.Visible = True
      End Sub
      
      Private Sub Form1_FormClosing(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing
        RadDock1.SaveToXml(file)
      End Sub
      
      Private Sub RadMenuItem1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RadMenuItem1.Click
        Static flag As Boolean
        If flag Then
          RadDock1.Visible = False
        Else
          RadDock1.Visible = True
        End If
        flag = Not flag
      End Sub
    End Class
    Now do the following:
    1. Run the project.
    2. Clik on the RadMenuItem1.
    3. Set the ToolWindow Floating.
    4. Close the form.
    5. Run the project again: the ToolWindow is visible even if the RadDock control isn't.
    How can I hide floating windows on startup? And make them visible again when RadDock1.Visible = True?

    Thank you very much
    Gianfranco
  2. Answer
    Richard Slade
    Richard Slade avatar
    3000 posts
    Member since:
    May 2009

    Posted 13 Jan 2011 Link to this post

    Hello,

    This should work for you.
    Public Class Form1
      
      
        Private file As String = "a.xml"
      
        Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
            Me.Visible = False
      
            If (System.IO.File.Exists(file)) Then RadDock1.LoadFromXml(file)
            RadDock1.Visible = False
            ManageToolWindowVisibility(False)
      
            Me.Visible = True
        End Sub
      
        Private Sub RadMenuItem1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RadMenuItem1.Click
            Static flag As Boolean
            If flag Then
                RadDock1.Visible = False
                ManageToolWindowVisibility(False)
            Else
                RadDock1.Visible = True
                ManageToolWindowVisibility(True)
            End If
            flag = Not flag
        End Sub
      
        Private Sub ManageToolWindowVisibility(ByVal show As Boolean)
            If show Then
                Me.ToolWindow1.Show()
            Else
                Me.ToolWindow1.Hide()
            End If
        End Sub
      
        Private Sub Form1_FormClosing(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing
            RadDock1.SaveToXml(file)
        End Sub
      
    End Class

    Hope that helps
    Richard
  3. UI for WinForms is Visual Studio 2017 Ready
  4. Richard Slade
    Richard Slade avatar
    3000 posts
    Member since:
    May 2009

    Posted 14 Jan 2011 Link to this post

    Hello,

    Did this help? If so please remember to mark as answer. If you need more assistance, let me know
    Thanks
    Richard
Back to Top