Vertical scrolling for windowsforms in c#

C

chris

hi all,

i need to create vertical scrollbar dynamically for the controls
that are created dynamically in the form. (i'm not adding any controls
to the panel). when the form exceeds(coz of dynamic controls creation)
the default system coordinates, vertical scroll bar should be
dynamically produced in the form.

in this case i could produce the vscrollbar dynamically. but when
i'm scrolling the form,the controls which are down couldn't be
scrolled up.

i'm doing it in this way,


if(height >= 600)
{
vsb=new VScrollBar();
vsb.Dock=DockStyle.Right;
vsb.Maximum = 600;
vsb.LargeChange = 250;
vsb.ValueChanged +=new EventHandler(vsb_ValueChanged);
Controls.Add(vsb);
}
....
....
....

private void vsb_ValueChanged(object sender, EventArgs e)
{
this.Top = -vsb.Value;
}


any suggestion in this regard would be greatly appreciated.

Thanks and Regards
chris
 
G

Guest

Hi Chris,
Couldn't you just set your forms AutoScroll property to true?

This way, scrollbars will automatically appear when needed, and disappear
when they are not.

Hope this helps.

All the best.
Phil.
 
C

christopher jayaseelan

thank u very much william, i didn't see the things on that perspect, as
i'm new to c#. thanks for yr timely help.
 
C

chris

hi all,
i got the answer from william.
it can be solved if we make autoscroll property of the form be true.

thanks and regards
chris
 

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

Top