PlanetSquires Forums

Support Forums => Other Software and Code => Topic started by: Jean-Pierre LEROY on May 31, 2005, 11:09:14 AM

Title: ListView doesn't scroll to the selected Item
Post by: Jean-Pierre LEROY on May 31, 2005, 11:09:14 AM
Hi,

I'm sorry, I've many questions about ListView control.

In this example I just load the ListView when I create the form with 50 lines; then I use the FF_ListView_SetSelectedItem to select the last item in the ListView; the row is well selected but the vertical scroll bar doesn't scroll to the last Item; I've to scroll manually to see the selected item.

Is-it a ListView issue ?

Here is the code

Function FORM1_WM_CREATE ( _
                        hWndForm As Dword, _  ' handle of Form
                        ByVal UserData As Long _  'optional user defined Long value
                        ) As Long

                       
FF_ListView_InsertColumn(HWND_FORM1_LISTVIEW1, 0, "Column1", %LVCFMT_RIGHT, 100)
FF_ListView_InsertColumn(HWND_FORM1_LISTVIEW1, 1, "Column2", %LVCFMT_RIGHT, 100)
FF_ListView_InsertColumn(HWND_FORM1_LISTVIEW1, 2, "Column3", %LVCFMT_RIGHT, 100)
FF_ListView_SetColumnAlignment (HWND_FORM1_LISTVIEW1, 0, %LVCFMT_RIGHT)

Local lrow As Long
Local lcol As Long
     
For lrow = 0 To 49
  For lcol = 0 To 2
      FF_ListView_InsertItem HWND_FORM1_LISTVIEW1, lrow, lcol, Str$(lrow) & Str$(lcol), 0, 0
  Next
Next

FF_ListView_SetSelectedItem (HWND_FORM1_LISTVIEW1, FF_ListView_GetItemCount (HWND_FORM1_LISTVIEW1)-1)

End Function

Thank you for your help.
Jean-Pierre
Title: ListView doesn't scroll to the selected Item
Post by: TechSupport on May 31, 2005, 01:37:18 PM
If you want to scroll the item into view then add this at the end of your code:


SendMessage HWND_FORM1_LISTVIEW1, %LVM_ENSUREVISIBLE, FF_ListView_GetItemCount (HWND_FORM1_LISTVIEW1)-1), %FALSE
Title: ListView doesn't scroll to the selected Item
Post by: Jean-Pierre LEROY on May 31, 2005, 03:08:27 PM
Hi Paul,

Thanks a lot, now I can see the line where the selected Item is in the ListView !

Jean-Pierre