HTML

 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me



Go Back   Tutorialized ForumsWeb Design & DevelopmentHTML

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 Tutorialized Forums Sponsor:
  #1  
Old October 17th, 2012, 04:54 AM
sejalmac sejalmac is offline
Registered User
Tutorialized Newbie (0 - 499 posts)
 
Join Date: Oct 2012
Posts: 2 sejalmac User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 13 m 16 sec
Reputation Power: 0
Richtext box scroll position is not maintained

I have rich text box and if i already have long text in it and if i try to start typing form that position the cursor remains at the position but the scroll bar scrolls to the top position.
If anybody can help will be really appriciate.
Thanks in advance.

Reply With Quote
  #2  
Old November 29th, 2012, 04:53 AM
VanessaMeacham VanessaMeacham is offline
Registered User
Tutorialized Newbie (0 - 499 posts)
 
Join Date: Sep 2012
Location: USA
Posts: 53 VanessaMeacham User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 14 h 59 m 31 sec
Reputation Power: 3
When you want to save the position, set the variable to the selection.start(or wherever else you intend on returning to). When you want to go back to the bookmark, use the ScrollToCaret method.

Below is an example.

Public Class Form1

Dim ibookmark As Integer

Private Sub btnBookMarkSet_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnBookMarkSet.Click
ibookmark = rtb.SelectionStart
End Sub

Private Sub btnBookMarkRestore_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnBookMarkRestore.Click
rtb.SelectionStart = ibookmark
rtb.ScrollToCaret()
End Sub

End Class


for the scroll bar is in the middle and i write a letter in the middle of the richtextbox then use below code :


Module ScrollBarPosition
Public Structure SCROLLINFO
Public cbSize As Integer
Public fMask As Integer
Public nMin As Integer
Public nMax As Integer
Public nPage As Integer
Public nPos As Integer
Public nTrackPos As Integer
End Structure
Declare Function GetScrollInfo Lib "user32" (ByVal hWnd As IntPtr, ByVal fnBar As Integer, ByRef lpsi As SCROLLINFO) As Integer
Public Function GetScrollBarPos(ByVal hWnd As IntPtr, ByVal fnBar As Integer) As Integer
Dim si As New SCROLLINFO
With si
.cbSize = Len(si)
.fMask = ScrollInfoMask.SIF_POS
'.nPos = 3
End With
Dim lRet As Integer = GetScrollInfo(hWnd, fnBar, si)
If lRet <> 0 Then
Return si.nPos
Else
Return -1
End If
End Function
Private Enum ScrollInfoMask
SIF_RANGE = &H1
SIF_PAGE = &H2
SIF_POS = &H4
SIF_DISABLENOSCROLL = &H8
SIF_TRACKPOS = &H10
SIF_ALL = SIF_RANGE + SIF_PAGE + SIF_POS + SIF_TRACKPOS
End Enum
Private Enum ScrollBarDirection
SB_HORZ = 0
SB_VERT = 1
End Enum

End Module

Reply With Quote
  #3  
Old November 29th, 2012, 04:57 AM
sejalmac sejalmac is offline
Registered User
Tutorialized Newbie (0 - 499 posts)
 
Join Date: Oct 2012
Posts: 2 sejalmac User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 13 m 16 sec
Reputation Power: 0
I have solved the problem . Though thank you for your reply....

Thanks ,
Sejal


Quote:
Originally Posted by VanessaMeacham
When you want to save the position, set the variable to the selection.start(or wherever else you intend on returning to). When you want to go back to the bookmark, use the ScrollToCaret method.

Below is an example.

Public Class Form1

Dim ibookmark As Integer

Private Sub btnBookMarkSet_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnBookMarkSet.Click
ibookmark = rtb.SelectionStart
End Sub

Private Sub btnBookMarkRestore_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnBookMarkRestore.Click
rtb.SelectionStart = ibookmark
rtb.ScrollToCaret()
End Sub

End Class


for the scroll bar is in the middle and i write a letter in the middle of the richtextbox then use below code :


Module ScrollBarPosition
Public Structure SCROLLINFO
Public cbSize As Integer
Public fMask As Integer
Public nMin As Integer
Public nMax As Integer
Public nPage As Integer
Public nPos As Integer
Public nTrackPos As Integer
End Structure
Declare Function GetScrollInfo Lib "user32" (ByVal hWnd As IntPtr, ByVal fnBar As Integer, ByRef lpsi As SCROLLINFO) As Integer
Public Function GetScrollBarPos(ByVal hWnd As IntPtr, ByVal fnBar As Integer) As Integer
Dim si As New SCROLLINFO
With si
.cbSize = Len(si)
.fMask = ScrollInfoMask.SIF_POS
'.nPos = 3
End With
Dim lRet As Integer = GetScrollInfo(hWnd, fnBar, si)
If lRet <> 0 Then
Return si.nPos
Else
Return -1
End If
End Function
Private Enum ScrollInfoMask
SIF_RANGE = &H1
SIF_PAGE = &H2
SIF_POS = &H4
SIF_DISABLENOSCROLL = &H8
SIF_TRACKPOS = &H10
SIF_ALL = SIF_RANGE + SIF_PAGE + SIF_POS + SIF_TRACKPOS
End Enum
Private Enum ScrollBarDirection
SB_HORZ = 0
SB_VERT = 1
End Enum

End Module

Reply With Quote
Reply

Viewing: Tutorialized ForumsWeb Design & DevelopmentHTML > Richtext box scroll position is not maintained


Developer Shed Advertisers and Affiliates


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 | 
  
 

Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.

© 2003-2014 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap