-
October 3rd, 2001, 01:49 PM
#1
ScrollBar in TextBox
I have TextBox wich displays several lines of text. Its height is enough to display 4 lines only. In case there are more than 4 lines I would like to add ScrollBar to the TextBox automatically. How can I do it?
Thank you
Vlad
-
October 3rd, 2001, 01:58 PM
#2
Re: ScrollBar in TextBox
Set its Scrollbars Property to 2(vertical).
-
October 3rd, 2001, 01:59 PM
#3
Re: ScrollBar in TextBox
Text1.ScrollBars=vbVertical
-
October 3rd, 2001, 02:02 PM
#4
Re: ScrollBar in TextBox
Thank you, but I do not want to have it always. I need the scrollbar only if displayed text doesn't fit the text box.
Vlad
-
October 3rd, 2001, 02:14 PM
#5
Re: ScrollBar in TextBox
In that case, your simplest option is to use a richtextbox instead... it'll put them on for you, otherwise you have to use the Sendmessage API to add and remove the scrollbars...
-
October 3rd, 2001, 02:17 PM
#6
Re: ScrollBar in TextBox
Determine how many lines in the text box and if more than 4 display scroll bar.
To count lines in the textbox
Private Declare Function SendMessage Lib "user32" Alias _
"SendMessageA" _
(ByVal hwnd As Long, _
ByVal wMsg As Long, _
ByVal wParam As Long, _
lParam As Any) As Long
Const EM_GETLINECOUNT = &HBA
'Call API to determine how many lines of text are in text box
LinesOfText = SendMessage(Text1.hwnd, EM_GETLINECOUNT, 0&, 0&)
and now you can
if LineOfText>4 then
Text1.ScrollBars = 2'vertical
else
Text1.ScrollBars = 0'none
end if
Iouri Boutchkine
iouri@hotsheet.com
-
October 3rd, 2001, 02:52 PM
#7
Re: ScrollBar in TextBox
Thank you very much. It's what I needed
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|