设为首页 加入收藏

TOP

Winform ListBox输出信息并自动滚动至底部
2019-09-23 11:18:26 】 浏览:39
Tags:Winform ListBox 输出 信息 自动 滚动 底部

应用场景: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);
   }
}

 

】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
上一篇获取List<object>中对象的.. 下一篇C# 调用Access数据库关于like模糊..

最新文章

热门文章

Hot 文章

Python

C 语言

C++基础

大数据基础

linux编程基础

C/C++面试题目