Need Help Adding Scrollable Region Space in a .NET DialogBox

Hello,

I have a question regarding DialogBoxes in Windows Applications using VB in the .NET 3.5 Framework (Visual Studio 2008).  My DialogBox is popped using a button from the main application window.  The  DialogBox contains alot of content, so I set the AutoScroll property of the DialogBox to True.

Most of the controls on the DialogBox are instantiated programatically (mainly UserControls and buttons).  A small problem is that the final control (a button) appears at the very bottom of the DialogBox after scrolling manually, with no space underneath it.  It would look alot better if I could add say 50 pixels of white space after the final button.

Is there a way to add the 50 pixels of white space after the final button, in the sense of increasing the scrollable height of the DialogBox, but without increasing the physical Height property of the DialogBox itself (i.e., I don't want to increase the "frame size" of the DialogBox, but just add about 50 pixels to the scrollable region under the final painted control)?

Thank you, Stu Engelman
stuengelmanAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

käµfm³d 👽Commented:
Try setting the bottom margin of the Button to 50.
0
Jacques Bourgeois (James Burger)PresidentCommented:
This is done through the AutoScrollMargin.Height property.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
stuengelmanAuthor Commented:
Hello Kaufmed and James,

I tried the following two options:

(1) btnMXClose.Margin.Bottom = 50
(2) Me.AutoScrollMargin.Height = Me.AutoScrollMargin.Height + 50

In both cases I get a design time error saying that "the expression is a value and cannot be the target of an assignment."  Is my syntax wrong, or are the properties read-only?

Thanks, Stu
0
Cloud Class® Course: SQL Server Core 2016

This course will introduce you to SQL Server Core 2016, as well as teach you about SSMS, data tools, installation, server configuration, using Management Studio, and writing and executing queries.

käµfm³d 👽Commented:
For mine, IIRC, Margin is a struct. As such, you have to assign a whole new Margin object, not just the Bottom property. I expected you would do this in the Properties window of the designer. No worry, though. You should be able to do:

btnMXClose.Margin = new Padding(0, 0, 0, 50)

Open in new window


I can't recall the default padding value for controls, but you can tinker with the zeros if you need to.
0
stuengelmanAuthor Commented:
Hi Kaufmed,

Your code compiles without problem, but has no impact on the DialogBox.  I suspect that's because there is no control below it.

Stu
0
stuengelmanAuthor Commented:
Hi All,

This did the trick: Me.SetAutoScrollMargin(0, 50)

Stu
0
stuengelmanAuthor Commented:
Solution not exact, but it pointed me in the right direction to getting the problem fixed.
0
Jacques Bourgeois (James Burger)PresidentCommented:
I might have been more precise in my answer. I when straight to the Height because this is something I usually set it in the Properties window of the Form, where there is an entry for the Width and another for the Height.

If you do it throught code, as you have found, you must call the SetAutoScrollMargin method.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic.NET

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.