Results 1 to 5 of 5

Thread: Removing Scroll bars from MDI Main

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Sep 2010
    Posts
    323

    Removing Scroll bars from MDI Main

    Hi there,

    Please have a look on attached file, this is MDI Parent form, when i move child form to lower bottom side, both horizontal and vertical scroll bars appears on MDI Main form. I don't want to show scroll bars on main mdi form, or in other words how can i hide scroll bars from main mdi form.

    I found several answers on google but not even a single work.
    Autoscroll property is also false but still i am getting scroll bars on parent mdi form.

    Please help me out how to remove scroll bars from mdi main parent form.

    Thanks
    LadakName:  Scroll_Bar.jpg
Views: 1759
Size:  15.7 KB

  2. #2
    Still learning kebo's Avatar
    Join Date
    Apr 2004
    Location
    Gardnerville,nv
    Posts
    3,757

    Re: Removing Scroll bars from MDI Main

    You can't remove the scroll bars (at least not with managed code), but since the mdiClient is simply another control in the forms collection, you get grab a reference to it and resize it so the scroll bars don't show.

    vb.net Code:
    1. 'find the mdiClient in the controls collection
    2.         For Each ctl As Control In Me.Controls
    3.             If TypeOf ctl Is MdiClient Then
    4.                 'got the control, so cast it
    5.                 Dim mdiClientControl As MdiClient = DirectCast(ctl, MdiClient)
    6.                 'undock it
    7.                 mdiClientControl.Dock = DockStyle.None
    8.                 'resize it
    9.                 mdiClientControl.Bounds = Me.ClientRectangle
    10.                 mdiClientControl.Height += 20
    11.                 mdiClientControl.Width += 20
    12.                 'set the anchors
    13.                 mdiClientControl.Anchor = AnchorStyles.Bottom Or AnchorStyles.Left Or AnchorStyles.Right Or AnchorStyles.Top
    14.  
    15.                 'bail out
    16.                 Exit For
    17.             End If
    18.         Next
    Process control doesn't give you good quality, it gives you consistent quality.
    Good quality comes from consistently doing the right things.

    Vague general questions have vague general answers.
    A $100 donation is required for me to help you if you PM me asking for help. Instructions for donating to one of our local charities will be provided.

    ______________________________
    Last edited by kebo : Now. Reason: superfluous typo's

  3. #3
    Hyperactive Member
    Join Date
    May 2011
    Posts
    256

    Re: Removing Scroll bars from MDI Main

    Hi guys
    I know this is an old post, but...
    I have Form2 show at load
    Without the code, Form2 shows under the MenuStrip
    Name:  without.jpg
Views: 1279
Size:  12.7 KB

    But with the code it shows behind MenuStrip
    Name:  with.jpg
Views: 1164
Size:  13.2 KB

    Any idea?
    Thanks

  4. #4
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    110,299

    Re: Removing Scroll bars from MDI Main

    Quote Originally Posted by threeeye View Post
    Any idea?
    That code starts by setting the Bounds of the MdiClient control to the ClientRectangle of the form. That means that its Location will be (0, 0). Just as the code then modifies the Height and Width properties, you would need to modify the Top property to move it down the height of the menu. I would expect something like this to work:
    vb.net Code:
    1. mdiClientControl.Top += Me.MenuStrip1.Height

  5. #5
    Hyperactive Member
    Join Date
    May 2011
    Posts
    256

    Re: Removing Scroll bars from MDI Main

    Quote Originally Posted by jmcilhinney View Post
    That code starts by setting the Bounds of the MdiClient control to the ClientRectangle of the form. That means that its Location will be (0, 0). Just as the code then modifies the Height and Width properties, you would need to modify the Top property to move it down the height of the menu. I would expect something like this to work:
    vb.net Code:
    1. mdiClientControl.Top += Me.MenuStrip1.Height
    Nice!
    Thanks!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width