By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
454,781 Members | 1,373 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 454,781 IT Pros & Developers. It's quick & easy.

Scrollbar Problem

P: n/a
I think I'm going nuts... Put a scroll bar control on a form and in the
form_load method, initialise it as follows:

vScrollBar.Minimum = 0;
vScrollBar.Maximum = 10;
vScrollBar.SmallChange = 1;
vScrollBar.LargeChange = 10;
vScrollBar.Value = 0;
vScrollBar.Visible = true;

In the vScrollBar_ValueChanged event, just display the current value of the
scroll bar. For example:
MessageBox.Show("Value: " + vScrollBar.Value);

When I run this, I expect to be able to click the arrow on the scroll bar to
scroll between 0 and 10. What I actually get is values between 0 and 1; I am
unable to scroll any further. I cannot get a value larger than 1.

Now, if I change the LargeChange value to 1, then everything works again.

Have I missed something fundamental about scroll bars here. I assumed that I
would be able to scroll (by the smallchange amount) from the minimum to the
maximum.

Any ideas? Do I have to intercept the "scroll" event and scroll myself?

Thanks
Steve
Mar 29 '06 #1
Share this Question
Share on Google+
6 Replies


P: n/a
>> Have I missed something fundamental about scroll bars here.

Yes, IMO, you have. How can the LargeChange value be the same as the
Maximum ? I tried your code, and when the LargeChange and the Maximum
are both set to 10, you see a large bar in between that just moves
between the values of 0 and 1.

However if you correct the LargeChange Value to something like 2, then
it will work just fine.

Hope this helps,.

Regards,

Cerebrus.

Mar 29 '06 #2

P: n/a
Yes, this is correct. It scrolls form min up to max-(largechange - 1)
This is done becaise it is expected that the largechange is the size of the
page. In your case you say that the apge is 10 pixels tall, that means the
first page is from 0-9 and the second page is one pixel tall. If you have
the scrollbar at position 0 there is only line one-pixel tall that is not
visible.
If this wasn't done like this when you move the scroll bar's thumb to the
max position you will see one empty page.

In order to get the full range set the LargeChange to 1.
--
HTH
Stoitcho Goutsev (100)

"Steve Barnett" <no****@nodomain.com> wrote in message
news:%2****************@TK2MSFTNGP11.phx.gbl...
I think I'm going nuts... Put a scroll bar control on a form and in the
form_load method, initialise it as follows:

vScrollBar.Minimum = 0;
vScrollBar.Maximum = 10;
vScrollBar.SmallChange = 1;
vScrollBar.LargeChange = 10;
vScrollBar.Value = 0;
vScrollBar.Visible = true;

In the vScrollBar_ValueChanged event, just display the current value of
the scroll bar. For example:
MessageBox.Show("Value: " + vScrollBar.Value);

When I run this, I expect to be able to click the arrow on the scroll bar
to scroll between 0 and 10. What I actually get is values between 0 and 1;
I am unable to scroll any further. I cannot get a value larger than 1.

Now, if I change the LargeChange value to 1, then everything works again.

Have I missed something fundamental about scroll bars here. I assumed that
I would be able to scroll (by the smallchange amount) from the minimum to
the maximum.

Any ideas? Do I have to intercept the "scroll" event and scroll myself?

Thanks
Steve

Mar 29 '06 #3

P: n/a
I suppose that makes sense, it just doesn't "feel" right. However, it does
explain what's happening and I suppose I could always set the "maximum"
value of my scroll bar to the required maximum + the largechange value.
That'd solve my specific needs.

Thanks
Steve
"Stoitcho Goutsev (100)" <10*@100.com> wrote in message
news:OR**************@tk2msftngp13.phx.gbl...
Yes, this is correct. It scrolls form min up to max-(largechange - 1)
This is done becaise it is expected that the largechange is the size of
the page. In your case you say that the apge is 10 pixels tall, that means
the first page is from 0-9 and the second page is one pixel tall. If you
have the scrollbar at position 0 there is only line one-pixel tall that is
not visible.
If this wasn't done like this when you move the scroll bar's thumb to the
max position you will see one empty page.

In order to get the full range set the LargeChange to 1.
--
HTH
Stoitcho Goutsev (100)

"Steve Barnett" <no****@nodomain.com> wrote in message
news:%2****************@TK2MSFTNGP11.phx.gbl...
I think I'm going nuts... Put a scroll bar control on a form and in the
form_load method, initialise it as follows:

vScrollBar.Minimum = 0;
vScrollBar.Maximum = 10;
vScrollBar.SmallChange = 1;
vScrollBar.LargeChange = 10;
vScrollBar.Value = 0;
vScrollBar.Visible = true;

In the vScrollBar_ValueChanged event, just display the current value of
the scroll bar. For example:
MessageBox.Show("Value: " + vScrollBar.Value);

When I run this, I expect to be able to click the arrow on the scroll bar
to scroll between 0 and 10. What I actually get is values between 0 and
1; I am unable to scroll any further. I cannot get a value larger than 1.

Now, if I change the LargeChange value to 1, then everything works again.

Have I missed something fundamental about scroll bars here. I assumed
that I would be able to scroll (by the smallchange amount) from the
minimum to the maximum.

Any ideas? Do I have to intercept the "scroll" event and scroll myself?

Thanks
Steve


Mar 29 '06 #4

P: n/a
Steve,

this is what all programers do when they implement scrolling in their
applications and MS embeded it in the scorllbar controls.
There is a TrackBar control that one can use to set values instead of
scrolling.
--

Stoitcho Goutsev (100)

"Steve Barnett" <no****@nodomain.com> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
I suppose that makes sense, it just doesn't "feel" right. However, it does
explain what's happening and I suppose I could always set the "maximum"
value of my scroll bar to the required maximum + the largechange value.
That'd solve my specific needs.

Thanks
Steve
"Stoitcho Goutsev (100)" <10*@100.com> wrote in message
news:OR**************@tk2msftngp13.phx.gbl...
Yes, this is correct. It scrolls form min up to max-(largechange - 1)
This is done becaise it is expected that the largechange is the size of
the page. In your case you say that the apge is 10 pixels tall, that
means the first page is from 0-9 and the second page is one pixel tall.
If you have the scrollbar at position 0 there is only line one-pixel tall
that is not visible.
If this wasn't done like this when you move the scroll bar's thumb to the
max position you will see one empty page.

In order to get the full range set the LargeChange to 1.
--
HTH
Stoitcho Goutsev (100)

"Steve Barnett" <no****@nodomain.com> wrote in message
news:%2****************@TK2MSFTNGP11.phx.gbl...
I think I'm going nuts... Put a scroll bar control on a form and in the
form_load method, initialise it as follows:

vScrollBar.Minimum = 0;
vScrollBar.Maximum = 10;
vScrollBar.SmallChange = 1;
vScrollBar.LargeChange = 10;
vScrollBar.Value = 0;
vScrollBar.Visible = true;

In the vScrollBar_ValueChanged event, just display the current value of
the scroll bar. For example:
MessageBox.Show("Value: " + vScrollBar.Value);

When I run this, I expect to be able to click the arrow on the scroll
bar to scroll between 0 and 10. What I actually get is values between 0
and 1; I am unable to scroll any further. I cannot get a value larger
than 1.

Now, if I change the LargeChange value to 1, then everything works
again.

Have I missed something fundamental about scroll bars here. I assumed
that I would be able to scroll (by the smallchange amount) from the
minimum to the maximum.

Any ideas? Do I have to intercept the "scroll" event and scroll myself?

Thanks
Steve



Mar 29 '06 #5

P: n/a
Steve,

I am not as diplotmatic about this as Stoitcho was. I think it was just a
huge screw up. When you set the maximum value in scroll bar you expect it
to reach the maximum. The fact that the help does not properly reflect what
is going on further suggests that it was stuff up:

More info here...
http://dotnetcoalface.blogspot.com/2...ggestions.html

Regards
Dave A

"Steve Barnett" <no****@nodomain.com> wrote in message
news:%2****************@TK2MSFTNGP11.phx.gbl...
I think I'm going nuts... Put a scroll bar control on a form and in the
form_load method, initialise it as follows:

vScrollBar.Minimum = 0;
vScrollBar.Maximum = 10;
vScrollBar.SmallChange = 1;
vScrollBar.LargeChange = 10;
vScrollBar.Value = 0;
vScrollBar.Visible = true;

In the vScrollBar_ValueChanged event, just display the current value of
the scroll bar. For example:
MessageBox.Show("Value: " + vScrollBar.Value);

When I run this, I expect to be able to click the arrow on the scroll bar
to scroll between 0 and 10. What I actually get is values between 0 and 1;
I am unable to scroll any further. I cannot get a value larger than 1.

Now, if I change the LargeChange value to 1, then everything works again.

Have I missed something fundamental about scroll bars here. I assumed that
I would be able to scroll (by the smallchange amount) from the minimum to
the maximum.

Any ideas? Do I have to intercept the "scroll" event and scroll myself?

Thanks
Steve

Mar 29 '06 #6

P: n/a
It works now and has become yet another piece of code surrounded by copious
comments explaining why I'm adding 'strange numbers' just to make it work
properly. This has to be, by far, one of the most unintuitive ways to code
that I have come across.

Still, having been bitten, I'll not get caught by this one again.

Thanks all
Steve

"Dave A" <da**@sigmasolutionsdonotspamme.com.au> wrote in message
news:Oy****************@TK2MSFTNGP11.phx.gbl...
Steve,

I am not as diplotmatic about this as Stoitcho was. I think it was just
a huge screw up. When you set the maximum value in scroll bar you expect
it to reach the maximum. The fact that the help does not properly reflect
what is going on further suggests that it was stuff up:

More info here...
http://dotnetcoalface.blogspot.com/2...ggestions.html

Regards
Dave A

"Steve Barnett" <no****@nodomain.com> wrote in message
news:%2****************@TK2MSFTNGP11.phx.gbl...
I think I'm going nuts... Put a scroll bar control on a form and in the
form_load method, initialise it as follows:

vScrollBar.Minimum = 0;
vScrollBar.Maximum = 10;
vScrollBar.SmallChange = 1;
vScrollBar.LargeChange = 10;
vScrollBar.Value = 0;
vScrollBar.Visible = true;

In the vScrollBar_ValueChanged event, just display the current value of
the scroll bar. For example:
MessageBox.Show("Value: " + vScrollBar.Value);

When I run this, I expect to be able to click the arrow on the scroll bar
to scroll between 0 and 10. What I actually get is values between 0 and
1; I am unable to scroll any further. I cannot get a value larger than 1.

Now, if I change the LargeChange value to 1, then everything works again.

Have I missed something fundamental about scroll bars here. I assumed
that I would be able to scroll (by the smallchange amount) from the
minimum to the maximum.

Any ideas? Do I have to intercept the "scroll" event and scroll myself?

Thanks
Steve


Mar 30 '06 #7

This discussion thread is closed

Replies have been disabled for this discussion.