Scroll Bar dans une listView

cs_jpp44 Messages postés 3 Date d'inscription dimanche 27 avril 2003 Statut Membre Dernière intervention 16 mai 2005 - 16 mai 2005 à 17:38
Gobillot Messages postés 3140 Date d'inscription vendredi 14 mai 2004 Statut Membre Dernière intervention 11 mars 2019 - 19 mai 2005 à 18:26
J'aimerai bouger le scroll bar d'une listview par le code

Merci d'avance

4 réponses

econs Messages postés 4030 Date d'inscription mardi 13 mai 2003 Statut Membre Dernière intervention 23 décembre 2008 24
16 mai 2005 à 20:09
Pas possible à ma connaissance, si ce n'est en changeant d'élément sélectionné.



Listview1.ListItems(1).EnsureVisible



Si tu changes le 1 en un nombre quelconque entre 1 et le nombre
d'éléments, la scrollbar bougera pour faire apparaître l'élément.

Manu
-------------------------------------------
Une question bien posée, c'est une chance de réponse bien adaptée.
0
Gobillot Messages postés 3140 Date d'inscription vendredi 14 mai 2004 Statut Membre Dernière intervention 11 mars 2019 34
16 mai 2005 à 23:57
Private Const WM_HSCROLL = &H114

Private Const WM_VSCROLL = &H115



Private Const SB_LINEUP = 0

Private Const SB_LINEDOWN = 1

Private Const SB_PAGEUP = 2

Private Const SB_PAGEDOWN = 3

Private Const SB_THUMBPOSITION = 4

Private Const SB_THUMBTRACK = 5

Private Const SB_TOP = 6

Private Const SB_BOTTOM = 7

Private Const SB_ENDSCROLL = 8



Private Const SB_LINELEFT = 0

Private Const SB_LINERIGHT = 1

Private Const SB_PAGELEFT = 2

Private Const SB_PAGERIGHT = 3

Private Const SB_LEFT = 6

Private Const SB_RIGHT = 7



Private Const SB_CTL = 2

Private Const SB_BOTH = 3



Private Enum HORZ_VERT

SB_HORZ = 0&

SB_VERT = 1&

End Enum




Public Enum SIF_MASK

SIF_RANGE = &H1&

SIF_page = &H2&

SIF_POS = &H4&

SIF_DISABLENOSCROLL = &H8&

SIF_TRACKPOS = &H10&

SIF_ALL = SIF_RANGE Or SIF_page Or SIF_POS

End Enum




Private Type SCROLLINFO

cbSize As Long

fMask As SIF_MASK

nMin As Long

nMax As Long

nPage As Long

nPos As Long

nTrackPos As Long

End Type




Private Declare Function GetScrollInfo Lib "user32" (ByVal hwnd As
Long, ByVal fnBar As HORZ_VERT, lpScrollInfo As SCROLLINFO) As Long



Private Declare Function SetScrollInfo Lib "user32" (ByVal hwnd As
Long, ByVal fnBar As HORZ_VERT, lpcScrollInfo As SCROLLINFO, ByVal
fRedraw As Boolean) As Long



Dim m_tagSCROLLINFO As SCROLLINFO



m_tagSCROLLINFO.cbSize = LenB(m_tagSCROLLINFO)

m_tagSCROLLINFO.fMask = SIF_ALL

Call GetScrollInfo(Lv.hwnd, SB_VERT, m_tagSCROLLINFO)



m_tagSCROLLINFO.nPos = m_tagSCROLLINFO.nMax

Call SetScrollInfo(Lv.hwnd, SB_VERT, m_tagSCROLLINFO, True)


voilà ça bouge bien la Scroll, mais ... surprise !!!!!!!



Daniel
0
econs Messages postés 4030 Date d'inscription mardi 13 mai 2003 Statut Membre Dernière intervention 23 décembre 2008 24
19 mai 2005 à 11:02
lol





Reste plus qu'à déterminer quel item est visible quand on a déplacé la scrollbar, et faire un EnsureVisible dessus.



Ton code répond parfaitement à la question. Mais est-ce exactement ce qu'il voulait ? lol




Manu
-------------------------------------------
Une question bien posée, c'est une chance de réponse bien adaptée.
0
Gobillot Messages postés 3140 Date d'inscription vendredi 14 mai 2004 Statut Membre Dernière intervention 11 mars 2019 34
19 mai 2005 à 18:26
ben oui, ça bouge la Scrollbar, mais pas ce qu'il y a dans la ListView !!!!

ce qui fait que quand on remonte manuellement la Scollbar, on peut se
retrouver avant le premier item, assez original, mais pas très
utilisable.

j'ai essayé avec des Sendmessage mais pas réussi ...


Daniel
0
Rejoignez-nous