Scrolling in ListView

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi!

I'm looking for a way to maintain the scrolling ability of a listView during
a drag&drop operation (necessary if the screen is too small to display all
the items of the lv), pretty much like the Windows Explorer does it - when
you hit the upper edge of the window it scrolls upwards.
By the way the AutoScroll property of my ListView is set to true.

Thanks already in advance!
 
Hi!
If you didn't find any solution, try this one.
Implement your drag&drop, then subscribe to DragOver event.
Insert the code below:

Point p = listView1.PointToClient(new Point(e.X, e.Y));
if (p.Y > listView1.Height - 10)
SendMessage(your_control.Handle, 0x0115, 1, 0);
else
if (p.Y < 10)
SendMessage(your_control.Handle, 0x0115, 0, 0);

You have to use P/Invoke:

[System.Runtime.InteropServices.DllImport("User32.dll")]
public extern static int SendMessage(IntPtr hwnd, uint message, int wparam,
int lparam);

Hope that helps.
Best regards.
 
By the way, do you happen to know how I can programmatically scroll down to a
certain coordinate after I perform my drag & drop operation (because I always
have to reload the entire listView to complete the drag & drop op.)?
- Should I probably just scroll down in a while loop until I've reached the
coordinates or is there also some kind of message?

Sorry to ask you again (but I've never really programmed using the Win32
API, thus I don't know what to look for).
 
Back
Top