473,811 Members | 2,915 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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

20 New Member
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 1533

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

Similar topics

0
1946
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 or a value list, etc. Can anyone point me in the right direction? Thanks!
11
109623
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
14584
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 information from the sender object or the EventArgs? How? Private Sub DataGridView1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles DataGridView1.Click Console.WriteLine("row number of cell is ?")
10
45219
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 event..., to no avail Any ideas Regards
3
7458
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 exceeds the DataGridView's height, it becomes impossible to view the out of sight portion of the row. Down arrow of the text cursor simply moves the caret down out of sight. Contrary to expectations, the DataGridView's scroll bar doesn't smoothly...
12
13662
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 display in a textbox below the datgridview. I currently have it fixed so if you click on a row the note field from that row is put in the textbox. I'd like this to be automatic as they move through rows. Also the note field is one of two fields...
0
2752
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
5295
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 dataGridView double C1; double INF1; double T1; //Read String values from each dataGridView Cell String^C1s = safe_cast<String^>(dataGridView1->Value); String^INF1s = safe_cast<String^>(dataGridView1->Value);
0
15253
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 should have a property of type DataGridViewAdvancedBorderStyle, this property you will change from the outside: 2. You will override also the PaintBorder, and Paint methods in a way that they will get the new property instead of the default one....
0
1230
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 dgv's cells and click the save button it fires the datagridview_cellvalidating event and if the cell validation is correct it updates and saves the current record to the datasource. Also, before save it commits change in any cell under editing. But...
0
10647
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10384
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
10130
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9204
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6887
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5553
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5692
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4338
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3865
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.