Click here to Skip to main content
15,896,063 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
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
Posted

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.
 
Share this answer
 
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.
 
Share this answer
 
v2
int thirdColumn = 2;
DataGridViewColumn col =
dataGridView.Columns[thirdColumn];
DataGridViewCell cell = new DataGridViewTextBoxCell();

cell.Style.BackColor = Color.Wheat;
col.CellTemplate = cell;
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900