如何使用csharp为数据网格视图中的行提供前景色和背景色 [英] how to give forecolor and background color for row in data grid view using csharp
问题描述
在Windows应用程序的数据网格视图中输出如下;
datepicker1 datepicker2
当我在datepicker2中选择datepicker1,在datapicker2中添加5天。因为那个日期我只给出前后地面颜色。
例如我提到了1/7/12和1 / 8月12日。
日期会议RK Mk CK Gk VK CMK CNN UNNi VB GS CM JN CA
1/7/12 1 REO Tasco AFF
1/7/12 2 REO Tasco AFF
1/7/12 3 REO Tasco AFF
1/7/12 4 REO Tasco AFF
1/8/12 1 REO Tasco AFF
1/8/12 2 REO Tasco AFF
1/8/12 3 REO Tasco AFF
1/8/12 4 REO Tasco AFF
来自输出数据网格视图
前颜色为浅蓝色和背景颜色为天蓝色的1/7/12日期
前面的颜色是浅棕色,背面颜色为紫色,在1/8/12日期
Output as follows in Data Grid View in Windows application;
datepicker1 datepicker2
when i select datepicker1 in datepicker2 5 days added in the datapicker2. for that date only i give the fore and back ground color.
for example i mentioned the 1/7/12 and 1/8/12 date .
Date Session RK Mk CK Gk VK CMK CNN UNNi VB GS CM JN CA
1/7/12 1 REO Tasco AFF
1/7/12 2 REO Tasco AFF
1/7/12 3 REO Tasco AFF
1/7/12 4 REO Tasco AFF
1/8/12 1 REO Tasco AFF
1/8/12 2 REO Tasco AFF
1/8/12 3 REO Tasco AFF
1/8/12 4 REO Tasco AFF
from the output Data Grid View
fore color has light blue and back ground color as Sky Blue in 1/7/12 date
fore color has light brown and back ground color as purple in 1/8/12 date
推荐答案
您之前的帖子中已经给出了建议这个问题: ho w为行提供前景色和背景色 [ ^ 一>]。如果您有进一步的信息,请更新原始问题,而不是再次发布相同的问题。
You have already been given a suggestion in your previous posting of this question: how to give forecolor and background color for row[^]. If you have further information then please update the original question, rather than posting the same question again.
拍摄,自2005年以来我没有尝试过,我的信息可能已经过时。如果我没记错的话,你必须在逐个单元的基础上做到这一点。每个Cell都有一个Style属性。
http://msdn.microsoft.com/en-us/library/system.windows.forms.datagridviewcell.style.aspx [ ^ ]
我我还要重申,我不喜欢DataGridViews,我觉得它们是可用性的祸根,所以在使用之前请先考虑一下。对于我在2005年写的内容,我切换到TreeView,一切都很甜美。
Shoot, I haven''t tried that since 2005 and my information may be out of date. If I recall correctly, you have to do that on a cell-by-cell basis. Each Cell has a Style property.
http://msdn.microsoft.com/en-us/library/system.windows.forms.datagridviewcell.style.aspx[^]
I''ll also repeat that I dislike DataGridViews and I feel that they are the bane of usability, so please think before using one. For what I was writing back in 2005, I switched to a TreeView and everything was sweetness and light.
int thirdColumn = 2;
DataGridViewColumn col =
dataGridView.Columns [thirdColumn];
DataGridViewCell cell = new DataGridViewTextBoxCell();
cell.Style.BackColor = Color.Wheat;
col.CellTemplate = cell;
int thirdColumn = 2;
DataGridViewColumn col =
dataGridView.Columns[thirdColumn];
DataGridViewCell cell = new DataGridViewTextBoxCell();
cell.Style.BackColor = Color.Wheat;
col.CellTemplate = cell;
这篇关于如何使用csharp为数据网格视图中的行提供前景色和背景色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!