| | |
Abnormal Behaviour of Vertical ScrollBar
Please support our VB.NET advertiser: $4.95 a Month - ASP.NET Web Hosting – Click Here!
![]() |
•
•
Join Date: May 2004
Posts: 6
Reputation:
Solved Threads: 0
Dear All,
In VB.net,
(1) Place a textbox on the form with bigger size and multiline property TRUE
(2) Allow AutoScroll of the form TRUE
(3) Run the application
(4) Resize the form in such a way that there should be vertical scrollBar along the form
(5) Now click on the textbox
Imazingly, Some area of textbox has been selected.
Why?
How should it be controlled?
Please response soon.
Thanks.
Regards,
Amir Ali.
In VB.net,
(1) Place a textbox on the form with bigger size and multiline property TRUE
(2) Allow AutoScroll of the form TRUE
(3) Run the application
(4) Resize the form in such a way that there should be vertical scrollBar along the form
(5) Now click on the textbox
Imazingly, Some area of textbox has been selected.
Why?
How should it be controlled?
Please response soon.
Thanks.
Regards,
Amir Ali.
Not sure I follow what you are saying. I did try it. By default the text (as the name of the textbox, in my case TextBox1) is automatically selected on startup. Why? That is because the control has focus.
If that is not what you want, then set the focus to another control on startup. In this case there is nothing else except the form itself.
Not sure if this helps, but maybe you could explain a little more by what you see as the problem with this?
If that is not what you want, then set the focus to another control on startup. In this case there is nothing else except the form itself.
Not sure if this helps, but maybe you could explain a little more by what you see as the problem with this?
•
•
Join Date: May 2004
Posts: 6
Reputation:
Solved Threads: 0
Dear Paladine,
Thanks for your response. I again try my best to make you clear about my problem.
Actually, when there would be vertical scrollbar along the form and position of scroll is most up. In this condition when we Click on RichTextBox, form will be scroll down. Thats why some area of RichTextbox is selected automatically. Position of form should not be changed by interacting with controls but it happens.
If you still not understand, then please just guide me how can I come to know that Windows scroll event is triggered and how I can prevent Form from being scrolled.
Many many Thanks.
Waiting for your reply,
Amir Ali.
Thanks for your response. I again try my best to make you clear about my problem.
Actually, when there would be vertical scrollbar along the form and position of scroll is most up. In this condition when we Click on RichTextBox, form will be scroll down. Thats why some area of RichTextbox is selected automatically. Position of form should not be changed by interacting with controls but it happens.
If you still not understand, then please just guide me how can I come to know that Windows scroll event is triggered and how I can prevent Form from being scrolled.
Many many Thanks.
Waiting for your reply,
Amir Ali.
•
•
•
•
Originally Posted by Amir Ali
Dear Paladine,
Thanks for your response. I again try my best to make you clear about my problem.
Actually, when there would be vertical scrollbar along the form and position of scroll is most up. In this condition when we Click on RichTextBox, form will be scroll down. Thats why some area of RichTextbox is selected automatically. Position of form should not be changed by interacting with controls but it happens.
If you still not understand, then please just guide me how can I come to know that Windows scroll event is triggered and how I can prevent Form from being scrolled.
Many many Thanks.
Waiting for your reply,
Amir Ali.
So I am not sure what the issue is? This is what should happen.
•
•
•
•
Position of form should not be changed by interacting with controls but it happens.
So a way around it? Not that I know of or see a reason to have one.
The only thing I could suggest is prevent resizing of the form.
Hope this helps, but if I am still not getting it...please clarify.
•
•
Join Date: May 2004
Posts: 6
Reputation:
Solved Threads: 0
Thats good you followed to some extent.
Now please give some more attention.
You resized the form and there is scrollbar. Now scroll should be must up. Means its vertical position value should be 0. And textbox should be large enough that we may see at least five lines at a time. Now click on textbox. Text will be selected even you are not likely to do that.
Thanks for your patience.
Now please give some more attention.
You resized the form and there is scrollbar. Now scroll should be must up. Means its vertical position value should be 0. And textbox should be large enough that we may see at least five lines at a time. Now click on textbox. Text will be selected even you are not likely to do that.
Thanks for your patience.
Amir I am paying attention, the text is not selected as you suggest. When the program/form is first started it is, but that is by default. As I mentioned before this is the result of the set focus method. Focus is set to the only control on the form by default.
I do exactly as you state, but my result is not what you say it should be.
Sorry dude, maybe someone else can make sense of this, but I see no issue what so ever.
I do exactly as you state, but my result is not what you say it should be.
Sorry dude, maybe someone else can make sense of this, but I see no issue what so ever.
•
•
Join Date: May 2007
Posts: 1
Reputation:
Solved Threads: 0
Did you ever find a solution to this problem? I am currently having the exact same problem you were trying to describe, and I can't figure out how to prevent the control from scrolling so that the textbox is aligned at the top of the window.
If you, or anyone else could help me out that would be greatly appreciated.
To try and describe the problem again as understandably as I can:
- I have a textBox (in fact it is a custom HtmlEditor that inherits from WebBrowser, but from this thread it seems the same thing can happen with a RichTextBox) that is larger than the control hosting it.
- I scroll so that an area in the middle of the textbox is visible.
- When I click in the textbox, the control automatically scrolls so that the top of the textbox is just visible.
- This scrolling seems to happen on mouseDown, because the result is the same as if i press the mouse button, scroll, and release the mouse button, so that lines of text are selected.
Eirik Ree
If you, or anyone else could help me out that would be greatly appreciated.
To try and describe the problem again as understandably as I can:
- I have a textBox (in fact it is a custom HtmlEditor that inherits from WebBrowser, but from this thread it seems the same thing can happen with a RichTextBox) that is larger than the control hosting it.
- I scroll so that an area in the middle of the textbox is visible.
- When I click in the textbox, the control automatically scrolls so that the top of the textbox is just visible.
- This scrolling seems to happen on mouseDown, because the result is the same as if i press the mouse button, scroll, and release the mouse button, so that lines of text are selected.
Eirik Ree
•
•
Join Date: Jun 2007
Posts: 1
Reputation:
Solved Threads: 0
Hello. I too ran into this problem. It occurs when a control obtains focus. It calls ScrollControlIntoView on its parent which moves the autoscroll position so the entire control can be shown. Since my issue was occuring in a panel, I just created a new class NoAutoScrollPanel, and inherited from Panel. I then added the following code:
ScrollToControl gives the position ScrollControlIntoView shoulds scroll to. This overriden version returns the current position. Now when you click a control the window won't scroll and no text will get selected.
VB.NET Syntax (Toggle Plain Text)
protected override Point ScrollToControl(System.Windows.Forms.Control activeControl) { return this.AutoScrollPosition; }
ScrollToControl gives the position ScrollControlIntoView shoulds scroll to. This overriden version returns the current position. Now when you click a control the window won't scroll and no text will get selected.
![]() |
Other Threads in the VB.NET Forum
- Previous Thread: List View Help....urgent !
- Next Thread: urgent!!!!!!!!!!
| Thread Tools | Search this Thread |
"crystal .net .net2005 30minutes 2005 2008 access account arithmetic array assignment basic box button buttons center check code component connectionstring convert crystalreport data database databasesearch datagrid datagridview date design dissertation dissertations dissertationthesis dosconsolevb.net dropdownlist excel fade file-dialog firewall folder ftp generatetags hardcopy image images input insert intel isnumericfuntioncall math monitor navigate net networking opacity output passingparameters peertopeervideostreaming picturebox picturebox1 port problem problemwithinstallation project record reports" savedialog searchvb.net select serial shutdown string survey tcp temp temperature text textbox timer toolbox trim updown user useraccounts usercontrol vb vb.net vb.netcode vb.netformclosing()eventpictureboxmessagebox vb.nettoolboxvisualbasic2008sidebar vb2008 vbnet view visual visualbasic visualbasic.net visualstudio visualstudio2008 web winforms wpf





