Winforms 数据网格是这种用法的最佳控件吗?
我正在编写一个日志客户端,它将侦听某个端口上传入的消息。
消息将通过 |分隔,并将包含以下内容:
[消息类型]|[消息]|[总任务的任务ID]| [时间] - 也许更多:
在我的 winforms 应用程序中,我想向用户显示此信息,我正在考虑将行添加到数据网格,但我需要网格自动滚动,并且可能需要颜色编码线。例如,如果是错误消息,则该行应为红色。
这是这项工作的最佳控制吗?
I am writing a logging client, that will listen for incoming messages on a certain port.
The message will come through | deliminated, and will contain the following:
[Type of message]|[message]|[taskID of total tasks]| [Time] - perhaps more:
In my winforms app I want to display this information to the user, I was thinking of adding rows to a data grid, but I would need the grid to autoscroll and perhaps have color coded lines. For example the row should be red, if it is an error message.
Is this the best control for the job?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
很难想象您会希望允许用户编辑此内容。因此,使用 View = Details 的 ListView 是合适的。使用 EnsureVisible() 自动滚动,使用 ListViewItem.BackColor 替换线条颜色。通过从中派生您自己的类并在构造函数中将 DoubleBuffered 属性设置为 true 来抑制闪烁。
Hard to imagine you'd want to allow the user to edit this. So a ListView with View = Details is appropriate. Autoscroll with EnsureVisible(), alternate line colors with ListViewItem.BackColor. Suppress the flicker you get by deriving your own class from it and setting the DoubleBuffered property to true in the constructor.