|2eM!x
Sep 23rd, 2005, 08:29 PM
All this requires is a textbox, and it will scroll to the line the user is on and
Option Explicit
Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" ( _
ByVal hWnd As Long, _
ByVal wMsg As Long, _
ByVal wParam As Long, _
lParam As Any _
) As Long
Private Const WM_VSCROLL = &H115
Private Const SB_PAGEDOWN = 3
Private Sub Command1_Click()
Call MoveToItem(ListView1, Text1, 1, 28)
End Sub
Private Function MoveToItem(lv As ListView, tb As TextBox, Column As Long, row As Long)
Dim i As Long, NumRows As Long, iRows As String
Dim iStr() As String
tb.BorderStyle = 0
tb.Top = lv.Top - 100: tb.Width = lv.ColumnHeaders(Column).Width
tb.Left = lv.ColumnHeaders(Column).Left + 190: tb.Height = 210
NumRows = (lv.Height / tb.Height) - 2
If row > NumRows Then
iRows = row Mod NumRows
If iRows <> "0" Then
iRows = row \ NumRows & ":" & iRows
iStr() = Split(iRows, ":")
End If
Else
iRows = "0" & ":" & row
iStr() = Split(iRows, ":")
End If
For i = 0 To iStr(1)
If row <> 0 Then
tb.Top = tb.Top + tb.Height
End If
Next i
If iStr(0) <> "0" Then
For i = 0 To CLng(iStr(0)) - 1
SendMessage lv.hWnd, WM_VSCROLL, SB_PAGEDOWN, ByVal 0&
Next i
End If
If Column = 1 Then
tb.Text = lv.ListItems(row).Text
Else
tb.Text = lv.ListItems(row).ListSubItems(Column - 1).Text
End If
tb.SetFocus
End Function
ill be adding some more cool stuff in the next few days..just hang on kids :wave:
Option Explicit
Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" ( _
ByVal hWnd As Long, _
ByVal wMsg As Long, _
ByVal wParam As Long, _
lParam As Any _
) As Long
Private Const WM_VSCROLL = &H115
Private Const SB_PAGEDOWN = 3
Private Sub Command1_Click()
Call MoveToItem(ListView1, Text1, 1, 28)
End Sub
Private Function MoveToItem(lv As ListView, tb As TextBox, Column As Long, row As Long)
Dim i As Long, NumRows As Long, iRows As String
Dim iStr() As String
tb.BorderStyle = 0
tb.Top = lv.Top - 100: tb.Width = lv.ColumnHeaders(Column).Width
tb.Left = lv.ColumnHeaders(Column).Left + 190: tb.Height = 210
NumRows = (lv.Height / tb.Height) - 2
If row > NumRows Then
iRows = row Mod NumRows
If iRows <> "0" Then
iRows = row \ NumRows & ":" & iRows
iStr() = Split(iRows, ":")
End If
Else
iRows = "0" & ":" & row
iStr() = Split(iRows, ":")
End If
For i = 0 To iStr(1)
If row <> 0 Then
tb.Top = tb.Top + tb.Height
End If
Next i
If iStr(0) <> "0" Then
For i = 0 To CLng(iStr(0)) - 1
SendMessage lv.hWnd, WM_VSCROLL, SB_PAGEDOWN, ByVal 0&
Next i
End If
If Column = 1 Then
tb.Text = lv.ListItems(row).Text
Else
tb.Text = lv.ListItems(row).ListSubItems(Column - 1).Text
End If
tb.SetFocus
End Function
ill be adding some more cool stuff in the next few days..just hang on kids :wave: