Getting TextBox scrollbar size

  • Thread starter Thread starter MuZZy
  • Start date Start date
M

MuZZy

Hi,

Is there a way to:
1. Find out if a scrollbar is currently show on the TextBox
2. Get the width of the horizontal scrollbar

I am doing a UserControl with a TextBox with a small image placed in the upper right cornet of the
text box. If user typed a lot of text and scrollbar shows, i need to catch the event and move the
image left so that it will not be hidden by the scroll bar.

Any ideas would be highly appreciated!

Thank you,
Andrey
 
MuZZy said:
Hi,

Is there a way to:
1. Find out if a scrollbar is currently show on the TextBox
2. Get the width of the horizontal scrollbar

I am doing a UserControl with a TextBox with a small image placed in the
upper right cornet of the text box. If user typed a lot of text and
scrollbar shows, i need to catch the event and move the image left so that
it will not be hidden by the scroll bar.

Any ideas would be highly appreciated!

What properties have you got set on the textbox so that the scrollbar
appears automatically? I could only get it to either be there all the time
or never appear.

As for the width I think you can use

System.Windows.Forms.SystemInformation.VerticalScrollBarWidth

Michael
 
Michael said:
What properties have you got set on the textbox so that the scrollbar
appears automatically? I could only get it to either be there all the time
or never appear.

TextBox.ScrollBars = Both/Horizontal/Vertical
When it's set to Both, it's automatic
As for the width I think you can use

System.Windows.Forms.SystemInformation.VerticalScrollBarWidth

I will take a look, thank you!
 
MuZZy said:
TextBox.ScrollBars = Both/Horizontal/Vertical
When it's set to Both, it's automatic

Don't know why but it's not automatic on my system. No matter what setting I
use the scrollbars just toggle between enabled and disabled. Maybe it's XP.

Michael
 
Back
Top