473,386 Members | 1,752 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

How to make a decision on the colour of a datagridview cell

Hi All,

Does anyone know if it is possible to check the cell colour at runtime and make a decision on it ?

I have a DGV that if the time in each cell is past a specific time it will paint the cell a particular color.

This ticks through once a minute. It works perfect.

The problem lies when I have a cell that is over a certain time I want to write to the audit and fire an email off. This works everytime the tick happens.

I tried
Expand|Select|Wrap|Line Numbers
  1.                     If DateAdd(DateInterval.Minute, 60, CDate(DataGridView1.Rows(y).Cells(x).Value)) < DateTime.Now.ToString("HH:mm") And DataGridView1.Rows(y).Cells(x).Style.BackColor = Drawing.Color.Yellow Then
  2.                         SendMail("Daily Process Behind Schedule By 60 minutes", DataGridView1.Rows(y).Cells(0).Value & " ----- " & DataGridView1.Rows(y).Cells(x).OwningColumn.Name.ToString)
  3.                         DBAction("INSERT INTO AUDIT (AUDIT_DATE, AUDIT_TIME, USERID, COMPANY, [ACTION], ACTION_DUE_TIME) VALUES ('" & DateTime.Now.ToString("dd/MM/yyyy") & "','" & DateTime.Now.ToString("HH:mm") & "','TaskManager Agent','" & DataGridView1.Rows(y).Cells(0).Value & "', 'Email Sent - Not Completed - " & DataGridView1.Rows(y).Cells(x).OwningColumn.Name.ToString & " - 60mins','" & DataGridView1.Rows(y).Cells(x).Value & "')")
  4.                         DataGridView1.Rows(y).Cells(x).Style.BackColor = Drawing.Color.Purple
  5.                         GoTo bypass
  6.                     End If
  7.  
But it is as if it doesn't know what the cell colour is. Even though it painted it in the last tick.

Is there another way I can set a property that will mean that only 1 audit entry is inserted and one email gets sent ?

Thanks in advance
Dennis
Nov 22 '11 #1
0 1514

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: Steve | last post by:
I am looking for an example of a custom user control ( 2 labels and 2 datetime pickers ) in a datagridview cell. Every example I have come across handles only once control such as a datetimepicker...
11
by: dgk | last post by:
Is there a way to change the foreground or background color of a single cell in an unbound datagridview?
3
by: Rich | last post by:
Hello, If I want to update data displayed in a datagrideview/datagridview cell, how can I determine what cell I am updating? I am looking at the click event below, for example. Can I get...
10
by: steve | last post by:
Hi All I would like to be able to change the cell borders on certain cells to none at runtime to make a group of cells appear to be merged I have tried the following in the cellformatting...
3
by: Richard Lewis Haggard | last post by:
I have an unbound DataGridView control that has some cells that may contain more multi-line text than can be completely displayed in the available screen space. When the height of its row to...
12
by: cj | last post by:
When viewing a datatable in a datagridview one of the columns in it is a "note" field which can be quite long. I would like to have the note field of the currently selected row of the datagrid...
0
by: varunk2 | last post by:
Hi How to autocomplete a datagridview cell in c# windows forms. Please anybody help me... Thanks in advance Regards,
0
by: hydro123 | last post by:
I am using VC++2008 and am trying to read data enetered in unbound datagridview to implement in function. Under button_click event I entered the following: // initialize varaibles from...
0
by: ziketo | last post by:
Hi, I searched a lot about changing the DataGridView cell borders. BYTES helped me so I will write down the solution: 1. You should override the class DataGridViewTextBoxCell, and the new class...
0
by: priyamtheone | last post by:
Problem in ToolStripButton (.Net 2008, Framework 3.5). Hi, I have an editable datagridview that's been databound with dataadapter and datatable, and a normal button on a form. When i edit the...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.