3
votes

I am new to the .Net Compact Framework and have been unable to find an answer via Google. Gasp! Yes, it's true, but that is part of why StackOverflow is here, right?

I have a form that is longer than the screen, so a vertical scroll-bar appears as expected. However, this appears to force a horizontal scroll-bar to appear as well. (If I scroll to the right, there is nothing visible except white space ... about the size of a scroll-bar.)

Is this a "feature" that is unavoidable? Anyone have experience in this area? ­­­­­­­­­­­­­­­­­­­­

3

3 Answers

2
votes

Place your controls within a panel or equivalent and then reduce the width of the panel by the size of a vertical scrollbar. That means that when the vertical scrollbar appears then it will no longer require the horizontal scrollbar to make up for the lost width that the vertical scrollbar took.

2
votes

You need to use the Anchor attribute on the controls.
Make the control Anchored to the Top, Left and Right.

When the form requires the vertical scrollbar the controls will resize instead of using the horizontal scrollbar.

Also you may find it easier to put all the controls into a Panel. Make the Panel the first control you add to your form.
Make the panel as big as the form, or lower than the bottom of the form is you need more space.
Set the anchor to Top, Left, Right. Set the autoscroll to true. On the Form turn autoscroll off.

Now put the controls into the Panel. You still need to set the anchor points on each of your controls or your Panel control will use the horizontal scrollbar and make the whole exercise pointless.
This is a good technique when you need to use the SIP(Soft Input Panel) as the Panels Height attribute can be altered when the SIP.Enabled attribute changes and prevents some of the controls being hidden by the SIP - it is annoying having to write text in a Textbox that you can't see.
The panel will provide the scrollbar as needed.

I'd say it is a good idea to put all controls in a Panel on the Form as adding it later can be a pain in the arse if the SIP is required later.

0
votes

Yes - I've got experience with that - unfortunately it was no different from your own. I've generally avoided scrolling forms and used paging wherever possible on .Net CF. If this is an option for you, I'd recommend it.

I'd assume the scroll bar issue is to do with the form size being fixed to the width of the available screen (regardless of design-time settings) so the introduction of a vertical scroll bar obscures part of the (not needed) full-width form.