Visual Basic Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming Languages - MoreVisual Basic Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old October 23rd, 2003, 08:13 PM
jeremyfang jeremyfang is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 2003
Posts: 1 jeremyfang User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Unhappy auto-scrolling of the scroll bar

Hello everyone,

I need help for writting a code in vb such that the vectical scrollbars that are placed in my project could move itself so as to display the last word of the text being displayed. When I display long text, the whole text is displayed but the scrollbar does not move to the end of the file.

Please help... Thank you

Reply With Quote
  #2  
Old October 25th, 2003, 11:22 PM
cleverpig cleverpig is offline
Contributing User
Dev Shed Beginner (1000 - 1499 posts)
 
Join Date: Jul 2003
Posts: 1,152 cleverpig User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 7
Send a message via MSN to cleverpig
I haven't found a way to implement auto scroll bar..But I find this code,Hope it is helpful to U:

Show a TextBox's vertical scrollbar only when it is necessary.

When the form loads, set a hidden PictureBox's Font property to match the TextBox's.
In the TextBox's Change event handler, use the PictureBox's TextHeight function to see how tall the text is. If the text is too big to fit in the TextBox, we need to display the scrollbar. If the need for the scrollbar has changed, use the ShowScrollBar API function to show or hide it.



Private m_ScrollBarVisible As Boolean

Private Declare Function ShowScrollBar Lib "user32" (ByVal _
hwnd As Long, ByVal wBar As Long, ByVal bShow As Long) _
As Long
Private Const SB_VERT = 1

Private Sub Form_Load()
' Make picHidden use the TextBox's font.
picHidden.Font = txtValue.Font

' Perform the initial startup check.
txtValue_Change
End Sub

Private Sub txtValue_Change()
Dim needs_scrollbar As Boolean

' See if we need the scrollbar.
needs_scrollbar = _
picHidden.TextHeight(txtValue.Text) > _
txtValue.Height - 60

' See if the need has changed.
If needs_scrollbar <> m_ScrollBarVisible Then
' Show or hide the scrollbar.
m_ScrollBarVisible = needs_scrollbar
ShowScrollBar txtValue.hwnd, SB_VERT, _
m_ScrollBarVisible
End If
End Sub

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreVisual Basic Programming > auto-scrolling of the scroll bar


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 6 hosted by Hostway
Stay green...Green IT