Click here to Skip to main content
14,458,350 members
Rate this:
Please Sign up or sign in to vote.
See more:
I have DataGridView, with three columns: Item Name, DateTime of Beginning of Auction, DateTime of closing of Auction (which is 5 minutes after the first DateTime).
I want to check if the time of closing expired and if it is expired, to change color of the that row. Aslo, if there is suggestion how to add countdown time for each row.
Thank you in advance

What I have tried:

Tried to find DataGridView property which handle this
Posted
Updated 20-Jun-19 22:17pm

1 solution

Rate this:
Please Sign up or sign in to vote.

Solution 1

Start with the DataGridView.RowPrePaint[^] event: it is called for row just before it is drawn. In it, check the expiry and set the foreground / background colours appropriately.

You will also need a Timer to Invalidate the DGV so that it does get repainted.

To set a "countdown timer" for each row, use the same event and timer, and update the row "countdown" column.
   
Comments
Sinisa Janjetovic 21-Jun-19 3:34am
   
Thank you, unfortunately I can not find it in Properties for DataGridView
OriginalGriff 21-Jun-19 3:37am
   
It's an Event, not a property.
Properties are for data, Events are for action as a result of things happening ... Look at the properties pane and click the little lightning bolt.
Sinisa Janjetovic 21-Jun-19 3:47am
   
I did, but there is no event RowPrePaint
Maciej Los 21-Jun-19 3:55am
   
Take a deeper look. If this event is available in MSDN documentation, then it should be available in your project, unless it isn't a WinForm project.
OriginalGriff 21-Jun-19 3:57am
   
What events can you see?
Sinisa Janjetovic 21-Jun-19 3:58am
   
Data Grid View is in Windows Form
OriginalGriff 21-Jun-19 4:07am
   
Yes, and it has a RowPrePaint event: what events can you see?
Sinisa Janjetovic 21-Jun-19 4:15am
   
Beginning with Row, I can see only RowDetailsVisibilityChanged, nothing else
OriginalGriff 21-Jun-19 4:45am
   
That's not a DataGridView, it's a DataGrid - which means it's WPF not WinForms.

You need to be accurate about these things when you ask questions!
Sinisa Janjetovic 21-Jun-19 4:47am
   
Sorry, I am beginner in C# and in Visual Studio at all, still learning and I am trying to manage.

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




CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100