To scroll the listview horizontally, I believe you'll have to use the
SendMessage API, e.g.
[DllImport("user32")]
static extern IntPtr SendMessage(IntPtr Handle, Int32 msg, IntPtr wParam,
IntPtr lParam);
protected void ScrollH(int pixelsToScroll)
{
const Int32 LVM_FIRST = 0x1000;
const Int32 LVM_SCROLL = LVM_FIRST + 20;
SendMessage(lvwList.Handle, LVM_SCROLL, (IntPtr) pixelsToScroll,
IntPtr.Zero);
}
To know when the user scrolls horizonatally, you'll need to capture the
WM_HSCROLL message in the WndProc() method, e.g.
protected override void WndProc(ref Message m)
{
const Int32 WM_HSCROLL = 0x114;
if (m.Msg == WM_HSCROLL)
HandleHorizontalScroll();
base.WndProc(ref m);
}
I'd recommend you subclass the ListView control and then add these methods
to it to achieve what you're looking for.
Ken
"Gary Brown" <ga********@charter.net> wrote in message
news:uY**************@TK2MSFTNGP09.phx.gbl...
Hi,
How do you programmatically scroll a ListView control horizontally?
(The same effect as if the user used the horizontal scroll bar,)
I've done it in C++/MFC, but can't find the means in C#. Autoscroll
is enabled.
Also, I need to know if the user scrolls the ListView horizontally.
Thanks,
Gary