0

I have a Parent Form with Graph Window as a child Window. In the parent form , there are buttons on the left side in panel. In the remaining area of the parent form , the child window will be shown. I am positioning the child windows manually in a following manner.

1st window

2nd window

3rd window , in vertical manner. So, this also creates a scroll bar on the right side of the parent form.

Once you click the graph button , the child window is created and positioned in the bottom of all other child windows. Since, a new window was added , scroll bar size needs to be refreshed as well. the vertical height of the bar only changes when I hover the cursor on the scroll bar. So, I click on the button on the left side, then to update the scroll bar I need to move the cursor on the scroll bar which is in the right side.

I tried to access the scroll bar but since it was automatically generated, i can not find a way to refresh it or give a focus manually.

Issue shown below: issue

this is how it should be

this is how it should be

I have uploaded a video to show the behavior and also a demo project. Demo project : http://www.filedropper.com/demoforscrollbar Screen share video : http://tinypic.com/r/ic0615/5

Is there anyway I can update the scroll bar without user cursor movement or user clicking on it?

I tried to change MdiParentForm.VerticalScroll.Minimum and maximum after opening or closing the child window, but it did not help. I also tried to disable and enable vertical scroll along with MdiParentForm.AdjustFormScrollbars , but did not work.

I have autoscroll = false, since I can not make it true in mdicontainer form. After i create the child window, I have written below in parent form.

    this.VerticalScroll.Minimum = 0;
    this.VerticalScroll.Maximum = this.MdiChildren[this.MdiChildren.Length -1].Location.Y + this.MdiChildren[this.MdiChildren.Length - 1].Height;
    this.AdjustFormScrollbars(true);            
    this.PerformLayout();
Glorfindel
  • 21,988
  • 13
  • 81
  • 109
saumil patel
  • 247
  • 5
  • 16

2 Answers2

1
Private Sub Form2_Move(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Move
    Me.ParentForm.PerformLayout()
End Sub

Link

Refresh scroll bars on winform

Community
  • 1
  • 1
Monika
  • 2,172
  • 15
  • 24
  • I forgot to mention, I already tried calling this.Performlayout() from parent form after I create or close the child window. scroll bar never reflected any changes. – saumil patel Nov 28 '13 at 06:18
  • @saumilpatel It sounds like you haven't set the Dock property of your PropertyGrid so its floating on top of the MdiClient. Set the PropertyGrid's Dock property to Right and then the MdiClient will be restricted to only the rest of the form and the scrollbars should appear where you want them to. – Monika Nov 28 '13 at 06:26
  • My issue is different from the link you provided. nothing is floating, everything is positioned properly. Scroll bar appears as well. Issue is strange behavior of scroll bar – saumil patel Nov 28 '13 at 06:44
0

I figured it out. missed very small thing. I needed to write

    this.Refresh(); 

after this.performlayout(); It did the trick.

saumil patel
  • 247
  • 5
  • 16