
November 29th, 2012, 03:57 AM
|
|
Registered User
|
|
Join Date: Oct 2012
Posts: 2
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 |
|