Windows Develop Bookmark and Share   
 index > Windows Forms Designer > Move scrollbar at top position
 

Move scrollbar at top position

hi all,
i have a window form on which i am creating progress bars & buttons at runtime. My form size is fix and when the number of controls increase than the size of the form,scroll bar is applied automatically with AutoScroll=True property.
I want that if scroll bar is on and controls(progress bar & buttons) are being added, then the scoll barshould alwaysmove to the top position. Means if the scoll bar is in moves down by the user, it should automatically move back to top.
How can i do this? It looks simple but i have not yet found how to do so.
Hope to hear the solution here.
Thanks in advance
maiqbal
Aamir Iqbal  Thursday, September 17, 2009 10:08 AM
I suppose that you want to scroll to the top whenever a set of controls are added. If so, first add the set of controls, and then add the following line of code:

this.ScrollControlIntoView(myTopControl);

where myTopControl represents the uppermost control that you want the user to see.
MCP
webJose  Saturday, September 19, 2009 4:51 AM

Thanks Jose for your reply.
I used the ScrollControlIntoView method as you directed but it did not do the job;the result was almost the same after using this method(i might haved used it wrongly).
Anyways, finally i have come up with the solution by setting the Y postion of the controls i am adding at runtime to the Y postion of the AutoScrollPosition property.

gb1.Location =

new Point(20, 0 + this.AutoScrollPosition.Y);


where gb1 is the GroupBox control i am creating at runtime that contains the ProgressBars & Buttons also created at runtime.




Thanks for your time,anyhow.


maiqbal
  • Marked As Answer byAamir Iqbal Thursday, September 24, 2009 6:15 AM
  •  
Aamir Iqbal  Thursday, September 24, 2009 6:15 AM
I suppose that you want to scroll to the top whenever a set of controls are added. If so, first add the set of controls, and then add the following line of code:

this.ScrollControlIntoView(myTopControl);

where myTopControl represents the uppermost control that you want the user to see.
MCP
webJose  Saturday, September 19, 2009 4:51 AM

Thanks Jose for your reply.
I used the ScrollControlIntoView method as you directed but it did not do the job;the result was almost the same after using this method(i might haved used it wrongly).
Anyways, finally i have come up with the solution by setting the Y postion of the controls i am adding at runtime to the Y postion of the AutoScrollPosition property.

gb1.Location =

new Point(20, 0 + this.AutoScrollPosition.Y);


where gb1 is the GroupBox control i am creating at runtime that contains the ProgressBars & Buttons also created at runtime.




Thanks for your time,anyhow.


maiqbal
  • Marked As Answer byAamir Iqbal Thursday, September 24, 2009 6:15 AM
  •  
Aamir Iqbal  Thursday, September 24, 2009 6:15 AM

You can use google to search for other answers

Custom Search

More Threads

• Detecting changes in nested properties using a PropertyGrid
• Second screen
• Problem with Form Display
• RichTextBox font not displaying Arial 11, displays Arial 11.5
• Scrollbars in a RichTexBox Control
• Serializing components to .resx
• Custom Component : Multi Panel Display, & CollectionEditor
• Deserialization
• EditorAttribute issue with Common Types
• Unable to select individual control on a Custom control