ListView scrollbars

E

Elisa

Hi,

Can I tell a ListView control to never add a horizontal (left/right)
scrollbar, i.e. only a vertical (up/down) scrollbar, and then only when
necessary?

For some reason, if I now populate a ListView with several icons, it
shows both a vertical and a horizontal scrollbar, but the horizontal
scrollbar can only scroll one or two pixels, and, most oddly, if you DO
scroll one or two pixels, it removes the horizontal scrollbar altoghether.


Regards,

Elisa
 
A

Alex Feinman [MVP]

I've got around this problem (in large icon view) by playing with icon
spacing by sending LVM_SETICONSPACING (0x1035) message to list view
 
E

Elisa

Hi Alex,
I've got around this problem (in large icon view) by playing with icon
spacing by sending LVM_SETICONSPACING (0x1035) message to list view

Mmm, to set the icon spacing to 36x36, I tried:

mLVIcons.Focus()
Dim hWnd As IntPtr = GetFocus()
SendMessage(hWnd, &H1035, 0, (36 << 16) Or (36 And &HFFFF))
mLVIcons.Invalidate()

....

<DllImport("coredll", SetLastError:=True)> _
Private Shared Function GetFocus() As IntPtr
End Function

<DllImport("coredll", SetLastError:=True)> _
Private Shared Function SendMessage(ByVal hWnd As IntPtr, ByVal msg As
Integer, ByVal wParam As Integer, ByVal lParam As Integer) As IntPtr
End Function

But apparently that is too simplistic ;-)


Regards,

Elisa
 
A

Alex Feinman [MVP]

Set a scrollbar (temporary) and on its event change the spacing to see the
results. Start with 76 and go up and down from there
 
E

Elisa

Hi Alex,
Set a scrollbar (temporary) and on its event change the spacing to see the
results. Start with 76 and go up and down from there

I meant that the code I posted doesn't seem to accomplish anything...


Regards,

Elisa
 
E

Elisa

Hi Alex,

Thanks for the example code. Sadly, if I try the same in my project, it
simply doesn't do anything :-(

The weird thing is, if I send the message, and retrieve the icon spacing
in a following SendMessage, it actually returns the new values
correctly, but visually nothing happens, not even if I do a
MyListView.Invalidate()... Very frustrating...

The only difference I can find between your code and mine, is that mine
is called inside a Modal form. Would that have anything to do with it?


Regards,

Elisa
 
A

Alex Feinman [MVP]

I wonder if the ListView properties might be different...
Could you try to insert a brand-new ListView and only add some items without
changing any properties? Also notice that I haven' tried to define any
columns - not sure if it matters
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top