9

I am developing a Windows Application in VB.Net. In that, there is one case where there is one form, and in that form there is a Panel, and within the Panel there is a rich text box.

So my requirement is to get a scrollbar in the Panel. So when the user does scroll on the panel, the rich text box can scroll accordingly like MS Office functionality..

Can any one give me an idea how to do it?

ABPerson
  • 489
  • 6
  • 22
Brijesh Patel
  • 2,901
  • 15
  • 50
  • 73

3 Answers3

20

Set Panel.AutoScroll = True and scrollbars will automatically appear whenever any controls in the panel fall outside its boundaries.

Peladao
  • 4,036
  • 1
  • 23
  • 43
  • You can also set the Panel's .Anchor properties so that it resizes with the form. – SSS Sep 21 '12 at 01:58
8

Set the .Dock property to FILL and the .WordWrap property to FALSE for the richtextbox.

Also set the Panel's .Dock property to FILL.

SSS
  • 4,807
  • 1
  • 23
  • 44
  • thanks for your quick reply.. i did what u said. at present scrollbar coming in richtextbox control but i want scrollbar in panel not in rich text box. – Brijesh Patel Sep 20 '12 at 07:23
6

In order to use panel autoscroll property I do that:

panel.AutoScroll = true
panel.VerticalScroll.Visible = False or panel.HorizontalScroll.Visible = False

In order to know the dimensions of the scroolbars use

SystemInformation.HorizontalScrollBarHeight
SystemInformation.VerticalScrollBarWidth

So you can change the dimension of the panel when the scroolbar is shown.

Myrne Stol
  • 11,222
  • 4
  • 40
  • 48
LangitKTV
  • 61
  • 1
  • 1