Removing ListView Scrollbars (II)

T

tom

BTW, don't press TAB to format your post and then hit
enter...like I did.

Like I said, I would like to replace a ListView's scroll
bars with buttons for easier use with a touch screen.

private static Int32 GWL_STYLE = (-16);
private static Int32 WS_VSCROLL = 0x00200000;
private static Int32 WS_HSCROLL = 0x00100000;
[DllImport("coredll")]
extern static IntPtr GetCapture();
[DllImport("coredll", CharSet=CharSet.Auto)]
internal static extern int SetWindowLong(IntPtr hWnd,
Int32 flag, int dwNewLong);
[DllImport("coredll", CharSet=CharSet.Auto)]
static internal extern Int32 GetWindowLong(IntPtr hWnd,
Int32 flag);

public static void removeListViewScrollBars
(System.Windows.Forms.ListView lV)
{
lV.Capture = true;
IntPtr iP = GetCapture();
Int32 GWret = GetWindowLong(iP,GWL_STYLE);
SetWindowLong(iP, GWL_STYLE, GWret & (~WS_VSCROLL));
lV.Capture = false;
}

I get 'real' return values from GetCapture and
GetWindowLong but...the scroll bar does not disappear.

I am calling after clearing, configuring and adding items
to the ListView, while it is disabled and invisible as
well as between BeginUpdate()/EndUpdate() calls.
 
A

Alex Yakhnin [eMVP]

Place the ListView on a Panel and make its size less then
on the size of the scroll bars.

HTH... Alex

P.S. You will have to send scroll messages to the ListView
to make it scroll...
 

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