Home » Community » Newbie corner » Coloring a row in a SqlArray
Coloring a row in a SqlArray [message #50154] |
Thu, 09 August 2018 14:34 |
Giorgio
Messages: 218 Registered: August 2015
|
Experienced Member |
|
|
Hi there,
is there a way to set the color of a row of a SqlArray basing on a value of the related record in the database?
I have this SqlArray and - according on the value of a certain field that is not shown on screen - the line itself should be green or not colored.
So far, I have set a callback to the post query event: mySqlArray.WhenPostQuery = THISBACK(ColorLines).
The ColorLines() method is as follows:
void MyApp::ColorLines()
{
for(int i = 0;i<mySqlArray.GetCount();i++) {
mySqlArray.SetCursor(i);
if(DB_data.IsAvailable(mySqlArray.GetKey()))
JobList.SetLineColor(i, LtGreen());
}
}
The DB_data.IsAvailable() method, checks the value of the field Available for the record: if the value is Y (yes) the method returns true, and the row will be colored in green. This approach works, indeed, but it seems to me really inefficient: to fill in the table I have just issued a select statement to the table, now I am issuing an additional select for each row of the table. Is there a way for me to set the color at the same tome when filling the table?
As a side question: to get the *value* of the primary key there is the very convenient method GetKey(). The problem is that it returns "the value of the current row's primary key". To go through all the rows, I have to use SetCursursor(i) in the for loop to make the i-th row the current one. Does it exist a method like GetKey(int i) that returns the value of the key of the i-th row?
Regards,
Gio
[Updated on: Thu, 09 August 2018 14:37] Report message to a moderator
|
|
|
Goto Forum:
Current Time: Wed May 15 13:12:00 CEST 2024
Total time taken to generate the page: 0.01271 seconds
|