Getting TextBox scrollbar size

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
 
M

Michael C

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
 
M

MuZZy

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!
 
M

Michael C

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
 

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