C# ListBox 垂直滚动条自动下滚方法

方法一:

 this.listBox1.SelectedIndex =  this.listBox1.Items.Count - 1;

方法二:

this.listBox1.TopIndex = this.listBox1.Items.Count - (int)(this.listBox1.Height / this.listBox1.ItemHeight);

 

方法三:
using System.Runtime.InteropServices;
[DllImport("User32.dll")]
private static extern Int32 SendMessage(IntPtr hWnd, int Msg, int wParam, int lParam);
public const int WM_VSCROLL = 0x0115;
public const int SB_BOTTOM = 7;
SendMessage(listBox1.Handle, WM_VSCROLL, SB_LINEDOWN, 0);

 

================================================

 

如果是WPF程序,可以用任意位置跳转方法:

listBox1.ScrollIntoView(listBox1.Items[0]);
原文地址:https://www.cnblogs.com/3Tai/p/2548391.html