Form cut off when displayed in splitcontainer

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • BrianP
    New Member
    • Jan 2009
    • 4

    Form cut off when displayed in splitcontainer

    I have a form that is currently being displayed in a split container with panel 1 holding a treeview and panel2 holding the form. my code for this is here. This is when selecting a item from the treeview.
    Code:
            Dim CurrentForm As New Form
            Select Case TreeView1.SelectedNode.Text
                Case Is = "Customer"
                    CurrentForm = Customer
                Case Is = "Quote"
                    CurrentForm = Quote
            End Select
    
            CurrentForm.FormBorderStyle = Windows.Forms.FormBorderStyle.None
            CurrentForm.ShowInTaskbar = False
            CurrentForm.IsMdiContainer = False
            CurrentForm.TopLevel = False
            CurrentForm.Visible = True
            CurrentForm.Anchor = CType((((System.Windows.Forms.AnchorStyles.Top Or System.Windows.Forms.AnchorStyles.Bottom) _
                        Or System.Windows.Forms.AnchorStyles.Left) _
                        Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles)
    
            SplitContainer1.Panel2.Controls.Clear()
            SplitContainer1.Panel2.Controls.Add(CurrentForm)
    When I view this in action however it cuts off about a quarter inch from the right of any form I use. Can anyone shed some light onto this for me?
    Last edited by Frinavale; Feb 6 '09, 08:49 PM. Reason: added [code] tags
  • nukefusion
    Recognized Expert New Member
    • Mar 2008
    • 221

    #2
    Usually a form is used as the outer-most container for other controls. It's not really designed for what you are trying to do. Is there any reason why you can't use a Panel control, or a TabControl with the tab headers hidden?

    Comment

    • BrianP
      New Member
      • Jan 2009
      • 4

      #3
      Thank you for the reply Nuke. The biggest reason is so that I do not have to re-design the controls and risk destroying something. It works great for some forms but not all of them.

      Comment

      • nukefusion
        Recognized Expert New Member
        • Mar 2008
        • 221

        #4
        If you have functionality that you want to reuse on those forms then I would spend a little time and split it out into a couple of user controls, i.e. a customer user control and a quote user control. That would be the recommended way to do it and will certainly behave more consistently.

        Comment

        • BrianP
          New Member
          • Jan 2009
          • 4

          #5
          Alright Nuke,

          Just for you I am experimenting with the user contol. So far it has been fairly painless to just copy over all the controls and then the code. It isn't cutting off the right side anymore but we will see how it ends up.

          Comment

          Working...