hello, i have listview with some items i wonder how to read position of scrollbar in that control? I want to maintain it in file and then resume to saved position....
thanks
Loading
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Blocked AccountPosted Sep 30, 2008, 3:36 AM
Hi,
try this code
Option Explicit On
Option Strict On
Imports System.Runtime.InteropServices.Marshal
Public Class Form1
Inherits System.Windows.Forms.Form
Dim si As New SCROLLINFO()
Declare Function GetScrollInfo Lib "user32" Alias "GetScrollInfo" _
(ByVal hWnd As IntPtr, ByVal n As Integer, ByRef
lpScrollInfo As SCROLLINFO) As Integer
Declare Function SetScrollInfo Lib "user32" Alias "SetScrollInfo" _
(ByVal hWnd As IntPtr, ByVal n As Integer, _
ByRef lpcScrollInfo As SCROLLINFO, ByVal bool As Boolean) As Integer
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
Private Const SB_HORZ As Integer = 0
Private Const SB_VERT As Integer = 1
Private Const SIF_RANGE As Integer = &H1
Private Const SIF_PAGE As Integer = &H2
Private Const SIF_POS As Integer = &H4
Private Const SIF_TRACKPOS As Integer = &H10
Private Const SIF_ALL As Integer = SIF_RANGE Or SIF_PAGE Or SIF_POS Or
SIF_TRACKPOS
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
si.cbSize = SizeOf(si)
si.fMask = SIF_ALL
GetScrollInfo(ListView1.Handle, SB_VERT, si)
si.nPos = si.nMax
SetScrollInfo(ListView1.Handle, SB_VERT, si, True)
End Sub
End Class