little-l

textbox只显示指定行数

利用队列
private Queue<string> logQueue = new Queue<string>(); private const int logMax = 100;

public void Log(string logText)
{
    // this should only ever run for 1 loop as you should never go over logMax
    // but if you accidentally manually added to the logQueue - then this would
    // re-adjust you back down to the desired number of log items.
    while (logQueue.Count > logMax - 1)
        logQueue.Dequeue();

    logQueue.Enqueue(logText);
    textBox.Text = string.Join(Environment.NewLine, logQueue.ToArray());
}
来源:https://stackoverflow.com/questions/18988170/making-a-net-textbox-work-fifo-style
发表于 2019-10-11 14:59  Little_L  阅读(316)  评论(0编辑  收藏  举报
 

分类:

技术点:

相关文章:

  • 2021-11-14
  • 2022-01-05
  • 2021-12-01
  • 2021-12-28
  • 2021-09-20
  • 2021-10-15
  • 2021-11-07
  • 2021-10-18
猜你喜欢
  • 2021-11-11
  • 2021-10-18
  • 2021-10-18
  • 2021-11-11
  • 2021-11-11
  • 2021-12-12
  • 2021-12-25
相关资源
相似解决方案