Winform ListBox输出信息并自动滚动至底部

mac2022-06-30  127

应用场景:ListBox作为软件信息的输出框。

//ListBox输出信息 internal void SetListBoxMessage(string str) { if (this.MessageListBox.InvokeRequired) { Action<string> actionDelegate = (x) => { MessageListBox.Items.Add(str); MessageListBox.TopIndex = MessageListBox.Items.Count - (int)(MessageListBox.Height / MessageListBox.ItemHeight); }; this.MessageListBox.Invoke(actionDelegate, str); } else { MessageListBox.Items.Add(str); MessageListBox.TopIndex = MessageListBox.Items.Count - (int)(MessageListBox.Height / MessageListBox.ItemHeight); }}

 

转载于:https://www.cnblogs.com/seanyan/p/11474006.html

相关资源:c# Listbox自动滚动
最新回复(0)