scr*_*789 10
你可以尝试一下:
listBox1.SelectedIndex = listBox1.Items.Count - 1;
listBox1.SelectedIndex = -1;
Run Code Online (Sandbox Code Playgroud)
此示例代码可以帮助您.我已经使用TextBox多次完成了这项工作,但是需要一段时间才能找到一个ListBox
显然,它只是一个带有Button和ListBox的Form.修改以满足您的需求:
private void button1_Click(object sender, EventArgs e)
{
listBox1.Items.Add("Some Text " + listBox1.Items.Count.ToString());
//The max number of items that the listbox can display at a time
int NumberOfItems = listBox1.ClientSize.Height / listBox1.ItemHeight;
if (listBox1.TopIndex == listBox1.Items.Count - NumberOfItems - 1)
{
//The item at the top when you can just see the bottom item
listBox1.TopIndex = listBox1.Items.Count - NumberOfItems + 1;
}
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
15373 次 |
| 最近记录: |