intro to scrollbars

  • Thread starter Thread starter johnmmcparland
  • Start date Start date
J

johnmmcparland

Hi all,

I'm trying to learn how to use scrollbars (in particular vertical
scrollbars) in windows forms. However every code sample I've looked at
or article I've read seems to miss out stuff.

I was wondering if anyone knows of a real dummies guide to using
VScrollBar on Windows Forms or could offer their own help?

Thanks,

John
 
Hi all,

I've read a wee bit into programming scrollbars, but I still can't
solve my problem.

I want to specify a maximum size for my form and if the largest y value
of my controls is greater than this then I want to start scrolling (and
not allow the user to increase the size).

ie.

if ((lastControl.Location.Y+lastControl.Size.Height) > maxY)
{
// set form height= maxY
// turn on auto scroll
// disable resizing
}

The following article seems to be the converse of this;

http://www.samspublishing.com/library/content.asp?b=STY_Csharp_24hours&seqNum=67&rl=1

but I'm still not sure what to do.

Can anyone suggets anything?
 
Funny how when you try to explain something to someone in order to ask
for help, you end up solving it yourself.

For anyone who may be interested, this is what I did;

1) set a maxiumum height for the Form
2) turned on autoscroll
3) // found last Control, c
int yVal= c.Location.Y + c.Size.Height;
if (yVal > this.MaxiumSize.Height)
this.Height= this.MaxiumSize.Height; // this is the form
else
this.Height= yVal + someVal; // someVal just a clearance space

easy eh?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top