Click here to Skip to main content
15,890,579 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Good Day to all.

I have a database which has a table field called "License_Expiration" that contains date and I will show this in a VB.NET datagridview


Now i just wanna ask How to change Datagridview Rows Colors by using the conditions below.


1.If License_Expiration will expire a month before the current date of expiration then the rows will change in dark green.

2.If License_Expiration will expire 10 days before the expiration then the color is light green

3.If License_Expiration meets the current date then it will turn red

4.If License_Expiration date has passed then it will turn yellow.



Please do help :(
Posted
Comments
Sergey Alexandrovich Kryukov 11-Jul-13 0:26am    
System.Windows.Forms? Tag: "WinForms".
—SA

Please see: http://msdn.microsoft.com/en-us/library/1yef90x0.aspx[^].

It will explain you how to have individual cell styles for some cells. And then, for a cell's style, use the property System.Windows.Forms.DataGridViewCellStyle.BackColor:
http://msdn.microsoft.com/en-us/library/system.windows.forms.datagridviewcellstyle.backcolor.aspx[^].

—SA
 
Share this answer
 
Comments
Crixalis Paul 11-Jul-13 0:43am    
Good Tutorial but sorry i will not Accept it "Accept Solution"
Sergey Alexandrovich Kryukov 11-Jul-13 0:59am    
Hm...
This is not a tutorial. It looks like it's not easy to help you. Not sure it worth the effort.
Take it easy,
—SA
The above answer explains pretty well on how to change colors etc.

DataGridViewCellStyle.BackColor Property

Well,you can implement that in following event
C#
private void dataGridView1_RowsAdded(object sender, DataGridViewRowsAddedEventArgs e)
{
   
}

Regards.. :laugh:
 
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