如何使用winform在后台保持活动的datagridview? [英] How to keep active datagridview in background using winform?

查看:101
本文介绍了如何使用winform在后台保持活动的datagridview?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

C#:我正在开发基于访问的数据库应用程序。 DataGridView中有一些text和date列。当系统时间和单元格日期相同时,日期列被编程为显示为红色。我希望DataGridView在后台自动激活,以便在时间结束时,即单元格为红色。系统托盘通知可能会出现,点击该通知应用程序时应该打开。在这需要代码不知道,因为我不是很专业。请帮忙。提前致谢。



我的尝试:



我是只能绘制我的datagridview单元格Red。在这方面无法做到。

C# : I am working on a access based Database application. In which DataGridView has some text and date columns. Date columns are programmed for appear red when system time and cell dates are same. I want DataGridView to automatically active in background so that when time is over i.e Cells are Red. A system tray notification may appear and on click of that notification application should be open. In this required no idea for code as i am not very expert. Please help. Thanks in advance.

What I have tried:

I was just able to paint my datagridview cell Red. Unable to do in this regard.

推荐答案

系统托盘通知通常是无模式的,因此它们不会干扰桌面上运行的应用程序。



要设置单元格的背景颜色,请执行以下操作:



System tray notifications are typically modeless so that they don't interfere with apps running on the desktop.

To set a cell's background color, do something like this:

DataGridViewCellStyle style = new DataGridViewCellStyle();
style.BackColor = Color.FromArgb(255,0,0);
style.ForeColor = Color.Black;
row.Cells[color.Index].Style = style;


我会这样做:我会用 BackgroundWorker [ ^ ]刷新数据源 [ ^ ] DataGridView和 DataGridView .CellFormatting事件 [ ^ ]格式化单元格。



请参阅:

使用BackgroundWorker的DataGrid - C# [ ^ ]

BackgroundWorker线程和支持取消 [ ^ ]

如何:自定义Windows窗体DataGridView控件中的数据格式Microsoft Docs [ ^ ]
I would do that this way: i'll use BackgroundWorker[^] to refresh DataSource[^] of DataGridView and DataGridView.CellFormatting Event[^] to format cells.

See:
DataGrid using BackgroundWorker - C#[^]
BackgroundWorker Threads and Supporting Cancel[^]
How to: Customize Data Formatting in the Windows Forms DataGridView Control | Microsoft Docs[^]


这篇关于如何使用winform在后台保持活动的datagridview?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆