Quantcast
Channel: Set ListView scroll position
Viewing all articles
Browse latest Browse all 11

Set ListView scroll position

$
0
0

Hi,

 

Subclass the ListView control and then add the method for horizontal scrolling as given by Ken over here

Code Snippet

[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);
}

 

 


HTH,

Suprotim Agarwal

 


Viewing all articles
Browse latest Browse all 11

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>