Best approach to Windows Forms rolling log output in TextBox(TextBox 中 Windows 窗体滚动日志输出的最佳方法)
问题描述
在 Forms 应用程序中,我正在显示来自生成大量输出的长时间运行的命令行应用程序的日志输出.我在后台启动程序,捕获它的输出,当前使用 AppendText 在 TextBox 中显示它.例如,我更喜欢只显示最后 1000 行.从 TextBox 中删除行的成本很高,而且 TextBox 并不是滚动日志显示的最佳方法.
In a Forms application I'm displaying log output from a long running command-line application that generated a lot of output. I start the program in the background, and capture its output and currently display it in a TextBox using AppendText. I prefer to only display for example the last 1000 lines. Removing lines from a TextBox is expensive, and a TextBox does not really feels like the best approach for rolling log display.
关于在 Windows 窗体中执行滚动日志窗口的最佳控件有什么想法吗?
Any ideas on the best Control to do a rolling log window in Windows Forms?
推荐答案
我曾经让列表框做这种事情.如果行数达到 1000,您只需删除第一行.如果日志行太长,您可以使列表框更宽一些(取决于日志信息以及是否有可能从第一个可见的没有水平滚动的单词)并使水平滚动条可见.
I used to have listboxes do this kind of thing. You just remove the first line if the line count reaches, say, 1000. If the log line is too long, you could make the listbox a bit wider (depends on the log information and whether it's possible to catch the meaning from the first visible words without horizontal scrolling) and make the horizonal scrollbar visible.
这篇关于TextBox 中 Windows 窗体滚动日志输出的最佳方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:TextBox 中 Windows 窗体滚动日志输出的最佳方法


基础教程推荐
- 经典 Asp 中的 ResolveUrl/Url.Content 等效项 2022-01-01
- 是否可以在 asp classic 和 asp.net 之间共享会话状态 2022-01-01
- 如何动态获取文本框中datagridview列的总和 2022-01-01
- 在 VS2010 中的 Post Build 事件中将 bin 文件复制到物 2022-01-01
- 全局 ASAX - 获取服务器名称 2022-01-01
- 从 VS 2017 .NET Core 项目的发布目录中排除文件 2022-01-01
- 首先创建代码,多对多,关联表中的附加字段 2022-01-01
- JSON.NET 中基于属性的类型解析 2022-01-01
- 错误“此流不支持搜索操作"在 C# 中 2022-01-01
- 将事件 TextChanged 分配给表单中的所有文本框 2022-01-01