Override ListBox class as following :
public class ListBoxScroll:ListBox {
private const int SB_HORZ=0;
private const int SB_VERT=1;
[System.Runtime.InteropServices.DllImport("user32.d ll")]
private static extern int GetScrollPos(int hWnd,int nBar);
[System.Runtime.InteropServices.DllImport("user32.d ll")]
private static extern int SetScrollPos(int hWnd,int nBar,int nPos,bool
bRedraw);
public int HScrollPos {
get {return GetScrollPos((int)Handle,SB_HORZ);}
set {SetScrollPos((int)Handle,SB_HORZ,value,true);}
}
public int VScrollPos {
get {return GetScrollPos((int)Handle,SB_VERT);}
set {SetScrollPos((int)Handle,SB_VERT,value,true);}
}
}
You have now two new members, called HScrollPos et VScrollPos. The last is
the one you are looking for.
Hope it helps,
Ludovic SOEUR.
"Sharon" <Sh****@discussions.microsoft.com> a écrit dans le message de
news:AF**********************************@microsof t.com...
I have a ListBox on my form and wand to do auto scrolling, I can do that
by: myListBox.ClearSelected();
OutputListBox.SelectedIndex = myListBox.Items.Count - 1;
But it causes to unselect all selected items, so I wish do that by moving
the vertical scroll bar, imbedded in the ListBox.
But I couldn't find a way to get the ListBox vertical scroll bar.
Can anybody show how to obtain it and how to make move/scroll??
--
Regards
Sharon G.