943,514 Members | Top Members by Rank

Ad:
  • VB.NET Discussion Thread
  • Unsolved
  • Views: 22001
  • VB.NET RSS
You are currently viewing page 1 of this multi-page discussion thread
May 21st, 2004
1

Abnormal Behaviour of Vertical ScrollBar

Expand Post »
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.
Reputation Points: 11
Solved Threads: 0
Newbie Poster
Amir Ali is offline Offline
6 posts
since May 2004
May 22nd, 2004
1

Re: Abnormal Behaviour of Vertical ScrollBar

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?
Team Colleague
Reputation Points: 211
Solved Threads: 27
Master Poster
Paladine is offline Offline
793 posts
since Feb 2003
May 24th, 2004
0

Re: Abnormal Behaviour of Vertical ScrollBar

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.
Reputation Points: 11
Solved Threads: 0
Newbie Poster
Amir Ali is offline Offline
6 posts
since May 2004
May 24th, 2004
0

Re: Abnormal Behaviour of Vertical ScrollBar

Quote 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.
Ok Amir, from the description you have given, I am sorry to say I do not see the issue. I resize the form and the scroll bar appears. The Textbox is now partially covered, and I can use the scroll bar to see the non-visible portion. Clicking on the textbox does nothing but place the cursor in the textbox.

So I am not sure what the issue is? This is what should happen.

Quote ...
Position of form should not be changed by interacting with controls but it happens.
This does not happen for me? Interacting with the control does not change the window position. But saying that, if you have another control (even another textbox) on this form and press the tab key the focus does go to the next control and the viewable portion of the resized form does change to the new control. Problem? Nope, that is a fact of life. Not a problem. This is how windows works. Otherwise you could type or select a not in view an have no Idea where you cursor was, or if you have selected the control you want.

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.


Team Colleague
Reputation Points: 211
Solved Threads: 27
Master Poster
Paladine is offline Offline
793 posts
since Feb 2003
May 24th, 2004
0

Re: Abnormal Behaviour of Vertical ScrollBar

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.
Reputation Points: 11
Solved Threads: 0
Newbie Poster
Amir Ali is offline Offline
6 posts
since May 2004
May 24th, 2004
0

Re: Abnormal Behaviour of Vertical ScrollBar

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.
Team Colleague
Reputation Points: 211
Solved Threads: 27
Master Poster
Paladine is offline Offline
793 posts
since Feb 2003
May 25th, 2004
0

Re: Abnormal Behaviour of Vertical ScrollBar

OK, no problem. Please do not mind. I could not describe my problem in a right way. Anyhow

Please just guide me how I come to know that when form's vertical scroll's position is changed (By coding or by user interaction) and how can i prevent it from scrolling.

Thanks for your patience.

Amir Ali.
Reputation Points: 11
Solved Threads: 0
Newbie Poster
Amir Ali is offline Offline
6 posts
since May 2004
May 21st, 2007
0

Re: Abnormal Behaviour of Vertical ScrollBar

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
Reputation Points: 10
Solved Threads: 0
Newbie Poster
eirikree is offline Offline
1 posts
since May 2007
May 22nd, 2007
0

Re: Abnormal Behaviour of Vertical ScrollBar

why don't you guys set focus points on the particular textbox or richtextbox you nead.

textbox1.focus()
Reputation Points: 347
Solved Threads: 13
Practically a Posting Shark
arjunsasidharan is offline Offline
812 posts
since Aug 2006
Jun 25th, 2007
0

Re: Abnormal Behaviour of Vertical ScrollBar

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:

VB.NET Syntax (Toggle Plain Text)
  1. protected override Point ScrollToControl(System.Windows.Forms.Control activeControl)
  2. {
  3. return this.AutoScrollPosition;
  4. }

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.
Reputation Points: 10
Solved Threads: 0
Newbie Poster
Polama is offline Offline
1 posts
since Jun 2007

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in VB.NET Forum Timeline: List View Help....urgent !
Next Thread in VB.NET Forum Timeline: urgent!!!!!!!!!!





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC