Article View: pl.comp.lang.vbasic
Article #92257Re: List View vb6
From: Marcin Miga
Date: Thu, 20 Oct 2005 11:59
Date: Thu, 20 Oct 2005 11:59
73 lines
2436 bytes
2436 bytes
janusz wrote:
> Witam
> Mam prosbe jak sterowac ListView aby przy dodawaniu nowych
> pozycji w sytuacji kiedy lista pozycji wychodzi poza wysokosc
> kontrolki byl widoczny ostatni wiersz listview
> polecenia
> ListView1.ListItems(ListView1.ListItems.Count).Selected = True
> ListView1.SelectedItem =
> ListView1.ListItems(ListView1.ListItems.Count) nie zalatwiaja sprawy
Czysta forma, ListView, Button.
Kod: (musisz sobie troche zmodyfikować, ale wiadomo o co chodzi.)
<CODE>
Option Explicit
Private Type POINTAPI
x As Long
y As Long
End Type
Private Const LVM_FIRST As Long = &H1000
Private Const LVM_SCROLL As Long = LVM_FIRST + 20
Private Const LVM_GETITEMPOSITION As Long = LVM_FIRST + 16
Private Declare Function SendMessage Lib "user32.dll" Alias
"SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As
Long, ByRef lParam As Any) As Long
Private Sub Command1_Click()
With ListView1
.SelectedItem = .ListItems.Add(, , .ListItems.Count + 1)
ListView_ScrollToItem .hwnd, .ListItems.Count
End With
End Sub
Private Function ListView_GetItemPosition(ByVal hWndLV As Long, ByVal
intIndex As Long) As POINTAPI
Dim paPosition As POINTAPI
If SendMessage(hWndLV, LVM_GETITEMPOSITION, intIndex, paPosition) Then
ListView_GetItemPosition = paPosition
End Function
Private Sub ListView_ScrollToItem(ByVal hWndLV As Long, ByVal intIndex
As Long)
Dim paPosition As POINTAPI
paPosition = ListView_GetItemPosition(hWndLV, intIndex)
SendMessage hWndLV, LVM_SCROLL, paPosition.x, paPosition.y
End Sub
Private Sub Form_Load()
With ListView1
.View = lvwReport
.LabelEdit = lvwManual
.HideSelection = False
.FullRowSelect = True
.ColumnHeaders.Add
End With
End Sub
</CODE>
pozdrawiaMM
--
Marcin M. Miga
"More matter with less art"
Technical Details
Message-ID:
<C57BDD8470737A4D9F2CE5DEE25D7B9007DCB63E@mailserver2.domdata.local>Path:
mbox-mo1.pugleaf.net!news-archive.icm.edu.pl!newsfeed.gazeta.pl!nf1.ipartners.pl!ipartners.pl!helios.domdata.com!DOMDATA3.BAUBODEN.comReferences:
<dj7t3t$ded$1@atlantis.news.tpi.pl>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-archive.icm.edu.pl!newsfeed.gazeta.pl!nf1.ipartners.pl!ipartners.pl!helios.domdata.com!DOMDATA3.BAUBODEN.com NNTP-Posting-Host: 192.168.151.148 Newsgroups: pl.comp.lang.vbasic Date: Thu, 20 Oct 2005 13:59:47 +0200 Message-ID: <C57BDD8470737A4D9F2CE5DEE25D7B9007DCB63E@mailserver2.domdata.local> From: "Marcin Miga" <Marcin.Miga[@]gmail.com> Subject: Re: List View vb6 References: <dj7t3t$ded$1@atlantis.news.tpi.pl> User-Agent: XanaNews/1.17.5.9 MIME-Version: 1.0 Lines: 74 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit