在 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 窗体滚动日志输出的最佳方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!