?
Solved

Need Help Adding Scrollable Region Space in a .NET DialogBox

Posted on 2011-10-22
8
Medium Priority
?
319 Views
Last Modified: 2012-05-12
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
0
Comment
Question by:stuengelman
  • 4
  • 2
  • 2
8 Comments
 
LVL 75

Expert Comment

by:käµfm³d 👽
ID: 37013219
Try setting the bottom margin of the Button to 50.
0
 
LVL 40

Accepted Solution

by:
Jacques Bourgeois (James Burger) earned 1500 total points
ID: 37013263
This is done through the AutoScrollMargin.Height property.
0
 

Author Comment

by:stuengelman
ID: 37013367
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
Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

 
LVL 75

Expert Comment

by:käµfm³d 👽
ID: 37013372
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
 

Author Comment

by:stuengelman
ID: 37013395
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
 

Author Comment

by:stuengelman
ID: 37013407
Hi All,

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

Stu
0
 

Author Closing Comment

by:stuengelman
ID: 37013410
Solution not exact, but it pointed me in the right direction to getting the problem fixed.
0
 
LVL 40
ID: 37014074
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

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (http://www.ecb.europa.eu/stats/exch…
This article shows how to deploy dynamic backgrounds to computers depending on the aspect ratio of display
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
When cloud platforms entered the scene, users and companies jumped on board to take advantage of the many benefits, like the ability to work and connect with company information from various locations. What many didn't foresee was the increased risk…

850 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question