Results 1 to 4 of 4

Thread: changing textbox scrollbars at runtime

  1. #1

    Thread Starter
    Hyperactive Member rajbdilip's Avatar
    Join Date
    Feb 2010
    Location
    Kathmandu, Nepal
    Posts
    263

    changing textbox scrollbars at runtime

    Hello. I want to change scrollbars of textbox at runtime. But i found it is read-only property. I have another option-to have double textbox. But i don't want to have this. So, is there any other option? May be we could do it by using API.

    Thanks.
    A Young Self-Taught Programmer || VB6 | VB.NET (Visual Studio 2010) | Java |CSS | JavaScript | PHP | MySQL

  2. #2
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: changing textbox scrollbars at runtime

    vb Code:
    1. Option Explicit
    2.  
    3. 'make sure scrollbars property is set to (0 NONE) and multiline is set to TRUE.
    4.  
    5. Private Declare Function ShowScrollBar Lib "user32" _
    6. (ByVal hwnd As Long, _
    7. ByVal wBar As Long, _
    8. ByVal bShow As Long) As Long
    9.  
    10. Private Const SB_HORZ = 0
    11. Private Const SB_CTL = 2 ' show or hides the entire control
    12. Private Const SB_VERT = 1
    13. Private Const SB_BOTH = 3
    14.  
    15. Private Sub Command1_Click()
    16. 'turn on horiztonal
    17. Call ShowScrollBar(Text1.hwnd, SB_HORZ, True)
    18. End Sub
    19.  
    20. Private Sub Command2_Click()
    21. 'turn them off
    22. Call ShowScrollBar(Text1.hwnd, SB_BOTH, False)
    23. End Sub

  3. #3
    New Member
    Join Date
    Jul 2010
    Posts
    11

    Re: changing textbox scrollbars at runtime

    1. Selecting a Normal Text Box and adding the code as said in the above reply is one method.

    2. Or else you can use RICHTEXTBOX instead of normal Text Box as this Richtextbox has a propery for scrolldown and you can select any one of the scroll type - eg. horizontal scroll or vertical scroll.

    The corresponding ocx for the richtextbox is RICHTX32.OCX

  4. #4
    PowerPoster
    Join Date
    Jul 2006
    Location
    Maldon, Essex. UK
    Posts
    6,334

    Re: changing textbox scrollbars at runtime

    Quote Originally Posted by [email protected] View Post
    Or else you can use RICHTEXTBOX instead of normal Text Box as this Richtextbox has a propery for scrolldown and you can select any one of the scroll type - eg. horizontal scroll or vertical scroll.
    I think you'll find that the ScrollBars property of a RichTextBox are Read only as they are for a TextBox.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width