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

Need To Disable Horizontal Scrolling - Why Is HScroll Property Ignored?

P: n/a
I have a user control that needs to allow vertical scrolling but not
horizontal scrolling. In the user control's resize event, I need to
adjust the size of all the children controls. For this to work
correctly, I need the AutoScroll to not enable the horizontal
scrollbar.

After researching MSDN, I found the HScroll which can be used to
disable horizontal scrolling when the AutoScroll mode is enabled.
However, when I disable HScroll, it gets re-enabled again when my user
control is resized. I tried disabling at the beginning and front of
the resize event handler of the user control, but it still flips back.

Any ideas on how to get this to work?

May 9 '07 #1
Share this Question
Share on Google+
3 Replies


P: n/a
Just a shot in the dark--I haven't used HScroll--but what if you disable it
in the Paint event? After a resize, the control is invalidated and painted,
and it may be getting enabled sometime during the paint.

--
Brian Schwartz
FishNet Components
http://www.fishnetcomponents.com
Fish Grid .NET Light: Powerful Layouts for Small Datasets
"j0rd4n" <jo***********@gmail.comwrote in message
news:11*********************@n59g2000hsh.googlegro ups.com...
>I have a user control that needs to allow vertical scrolling but not
horizontal scrolling. In the user control's resize event, I need to
adjust the size of all the children controls. For this to work
correctly, I need the AutoScroll to not enable the horizontal
scrollbar.

After researching MSDN, I found the HScroll which can be used to
disable horizontal scrolling when the AutoScroll mode is enabled.
However, when I disable HScroll, it gets re-enabled again when my user
control is resized. I tried disabling at the beginning and front of
the resize event handler of the user control, but it still flips back.

Any ideas on how to get this to work?

May 9 '07 #2

P: n/a
Or, as Peter Duniho has pointed out, you might want to override OnPaint to
accomplish this, rather than attaching to the event, depending on your
situation.

--
Brian Schwartz
FishNet Components
http://www.fishnetcomponents.com
Fish Grid .NET Light: Powerful Layouts for Small Datasets
"Brian Schwartz" <ow***@fishnetcomponentswos.comwrote in message
news:e5**************@TK2MSFTNGP06.phx.gbl...
Just a shot in the dark--I haven't used HScroll--but what if you disable
it in the Paint event? After a resize, the control is invalidated and
painted, and it may be getting enabled sometime during the paint.

--
Brian Schwartz
FishNet Components
http://www.fishnetcomponents.com
Fish Grid .NET Light: Powerful Layouts for Small Datasets
"j0rd4n" <jo***********@gmail.comwrote in message
news:11*********************@n59g2000hsh.googlegro ups.com...
>>I have a user control that needs to allow vertical scrolling but not
horizontal scrolling. In the user control's resize event, I need to
adjust the size of all the children controls. For this to work
correctly, I need the AutoScroll to not enable the horizontal
scrollbar.

After researching MSDN, I found the HScroll which can be used to
disable horizontal scrolling when the AutoScroll mode is enabled.
However, when I disable HScroll, it gets re-enabled again when my user
control is resized. I tried disabling at the beginning and front of
the resize event handler of the user control, but it still flips back.

Any ideas on how to get this to work?


May 9 '07 #3

P: n/a
Unfortunately this didn't work quite like I had hoped. It worked in
some cases but not others. For instance, if the application starts up
maximized but the control needs scrollbars, and then it is restored to
its non-maximized size, the horizontal scrollbar appears.

Any other ideas? I tried using the Win32 ShowScrollBar method to
disable the horizontal scrollbar but this just hide it (didn't
actually affect the horizontal sizing of the form).

On May 9, 4:02 pm, "Brian Schwartz" <o...@fishnetcomponentswos.com>
wrote:
Just a shot in the dark--I haven't used HScroll--but what if you disable it
in the Paint event? After a resize, the control is invalidated and painted,
and it may be getting enabled sometime during the paint.

--
Brian Schwartz
FishNet Componentshttp://www.fishnetcomponents.com
Fish Grid .NET Light: Powerful Layouts for Small Datasets

"j0rd4n" <jordan.par...@gmail.comwrote in message

news:11*********************@n59g2000hsh.googlegro ups.com...
I have a user control that needs to allow vertical scrolling but not
horizontal scrolling. In the user control's resize event, I need to
adjust the size of all the children controls. For this to work
correctly, I need the AutoScroll to not enable the horizontal
scrollbar.
After researching MSDN, I found the HScroll which can be used to
disable horizontal scrolling when the AutoScroll mode is enabled.
However, when I disable HScroll, it gets re-enabled again when my user
control is resized. I tried disabling at the beginning and front of
the resize event handler of the user control, but it still flips back.
Any ideas on how to get this to work?

May 10 '07 #4

This discussion thread is closed

Replies have been disabled for this discussion.