Highlight Delphi TwwDBGrid Cell
I have a program that a call center uses to guide phone agents through a script and gather information. Column 1 ("Question") is a text block that identifies what data is to be gathered ("Name", "Phone", "Address", etc.), Column 2 ("Response") is a free form text field for entering the information.
Each row in this grid is associated with a script the agents are to read, "Thank you for calling, can I have your name please?", and the response to this would go into the "Response" column. There are anywhere between 10-25 rows depending on who is calling and occasionally the agent will have to jump around from row to row based on how the call proceeds (i.e., the caller may not want to give all their info until they know the price of a service).
What开发者_开发问答 I would like to do is highlight each cell in the "Response" column to indicate that the agent has NOT yet visited that field (and not read the script associated with that row). Once the agent clicks on the "response" cell I want the highlighting to disappear and just have the standard background color.
Does anyone know how I would accomplish this? I don't see a OnCellClick event that I can call to change the color of the cell.
EDIT:
I am using Delphi 2005 and I was mistaken on what I am using for the grid. I am actually using Infopower's TwwDBGrid and there is no OnCellClick event.Edit: This answer was written when the question states a TDBGrid and not a TwwDBGrid as it states now, clearly the answer is wrong for that class.
You can have a set of boolean flags to track if a particular row was visited. On the call begining, initialize the flag set.
To track the "visited" fields, you can rely on the OnColEnter event and set the flag for that particular part of the script.
Then, rely on the OnDrawColumnCell to paint the background of each cell in the response column according to the associated VisitedFlag, highlighting the not yet visited ones.
TwwDBGrid supports the OnColEnter and OnCelExit events. It also has an OnRowChanged event to detect scrolling to a another record. So jachguate's answer is still valid.
精彩评论