Listview

G

Guest

I know that I can use ensurevisible to move to a specific item(row) in list
view. How about moving to some specific columns? Because I want to focus last
column when I add one in the listview which is autoscroll = true.

Thanks for your help

Ray
 
J

Jason Newell

Ray,
You can use you can send the LVM_SCROLL message to the listview to tell
it to scroll. Here is some of what you'll need.

http://msdn.microsoft.com/library/d...orm/commctls/listview/messages/lvm_scroll.asp

public enum ListViewMessages : int
{
LVM_FIRST = 0x1000,
LVM_SCROLL = (LVM_FIRST + 20)
}

[DllImport("User32", CharSet=CharSet.Auto)]
public static extern IntPtr SendMessage(IntPtr hWnd, int msg, int
wParam, int lParam);

private void ScrollToEnd(int width)
{
// You'll have to figure out the width in pixels. I didn't have time.
SendMessage(this.listView1.Handle, (int)ListViewMessages.LVM_SCROLL,
width, 0);
}


Jason Newell, MCAD
Software Engineer
 
G

Guest

Jason,

It works. Thanks a lot. By the way, can I know the size of thumb track and
indicator in scroll bar?

Thank you very very much,

Ray

Jason Newell said:
Ray,
You can use you can send the LVM_SCROLL message to the listview to tell
it to scroll. Here is some of what you'll need.

http://msdn.microsoft.com/library/d...orm/commctls/listview/messages/lvm_scroll.asp

public enum ListViewMessages : int
{
LVM_FIRST = 0x1000,
LVM_SCROLL = (LVM_FIRST + 20)
}

[DllImport("User32", CharSet=CharSet.Auto)]
public static extern IntPtr SendMessage(IntPtr hWnd, int msg, int
wParam, int lParam);

private void ScrollToEnd(int width)
{
// You'll have to figure out the width in pixels. I didn't have time.
SendMessage(this.listView1.Handle, (int)ListViewMessages.LVM_SCROLL,
width, 0);
}


Jason Newell, MCAD
Software Engineer
I know that I can use ensurevisible to move to a specific item(row) in list
view. How about moving to some specific columns? Because I want to focus last
column when I add one in the listview which is autoscroll = true.

Thanks for your help

Ray
 
J

Jason Newell

Ray,
I'm sorry, but I do not have time to work up an example for you, but
here are some hints that might help.

SBM_GETSCROLLBARINFO & SCROLLBARINFO are defined in: ..\Microsoft Visual
Studio .NET 2003\Vc7\PlatformSDK\Include\WinUser.h

http://msdn.microsoft.com/library/d...ce/scrollbarmessages/sbm_getscrollbarinfo.asp
http://msdn.microsoft.com/library/d...ference/scrollbarstructures/scrollbarinfo.asp

Good luck!


Jason Newell, MCAD
Software Engineer

Jason,

It works. Thanks a lot. By the way, can I know the size of thumb track and
indicator in scroll bar?

Thank you very very much,

Ray

:

Ray,
You can use you can send the LVM_SCROLL message to the listview to tell
it to scroll. Here is some of what you'll need.

http://msdn.microsoft.com/library/d...orm/commctls/listview/messages/lvm_scroll.asp

public enum ListViewMessages : int
{
LVM_FIRST = 0x1000,
LVM_SCROLL = (LVM_FIRST + 20)
}

[DllImport("User32", CharSet=CharSet.Auto)]
public static extern IntPtr SendMessage(IntPtr hWnd, int msg, int
wParam, int lParam);

private void ScrollToEnd(int width)
{
// You'll have to figure out the width in pixels. I didn't have time.
SendMessage(this.listView1.Handle, (int)ListViewMessages.LVM_SCROLL,
width, 0);
}


Jason Newell, MCAD
Software Engineer
I know that I can use ensurevisible to move to a specific item(row) in list
view. How about moving to some specific columns? Because I want to focus last
column when I add one in the listview which is autoscroll = true.

Thanks for your help

Ray
 

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