Scroll bar in Textbox(thanks to JCIS)
Dear All,
I found this (thanks to JCIS)code to set the scroll bar to text box when it necessary.It works good .But i face one problem.It is not scrolling when i click the scroll bar.Can some body help. I studied the problem as I have set the multiline to False, ,Because I dont want to allow the user to type more than one line
Re: Scroll bar in Textbox(thanks to JCIS)
That code is working perfectly for me.
Did you remember to "Set Multiline property = true and Scrollbars property = Both" at design time ?
Re: Scroll bar in Textbox(thanks to JCIS)
Dear IPrank,
I want to restrict the user to only one line.So I set the Multiline=False.Is there any method to solve this issue?
Show/hide Scrollbar On a SingleLine TextBox
Here is a little modified version of jcis's code that works on SingleLine textboxes.
This is actually a MultiLine text box, but it simulates like a singleline textbox.
Set Multiline = True and Scrollbar = Horizontal at designtime.
VB Code:
Option Explicit
Private Declare Function ShowScrollBar Lib "user32" _
(ByVal hWnd As Long, ByVal wBar As Long, _
ByVal bShow As Long) As Long
Private Const SB_HORZ = 0
Private Sub Form_Load()
CheckScrollBars
End Sub
Private Sub Text1_Change()
CheckScrollBars
End Sub
Private Sub CheckScrollBars()
If Me.TextWidth(Text1.Text) > (Text1.Width - 100) Then 'Wider than width?
ShowScrollBar Text1.hWnd, SB_HORZ, True 'Make HScrollbar visible
Else
ShowScrollBar Text1.hWnd, SB_HORZ, False 'Hide HScrollbar
End If
End Sub
Private Sub Text1_KeyPress(KeyAscii As Integer)
If KeyAscii = 10 Or KeyAscii = 13 Then KeyAscii = 0
End Sub
Re: Scroll bar in Textbox(thanks to JCIS)
Dear IPrank,
Thanks for your reply.It is not scrolling.?
Re: Scroll bar in Textbox(thanks to JCIS)
If the user can only type one line of text what is there to scroll? :confused:
Re: Scroll bar in Textbox(thanks to JCIS)
If the Text contents is more than the width of the textbox then there should be scrollbar to scroll.?
Re: Scroll bar in Textbox(thanks to JCIS)
I think I can close this thread if this is solved :)
Re: Scroll bar in Textbox(thanks to JCIS)
Edited my previous code. it should work now.