Scrolling in ListView

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!
 
A

Adrian

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.
 
G

Guest

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).
 

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