Home » Community » Newbie corner » Coloring a row in a SqlArray
Re: Coloring a row in a SqlArray [message #50186 is a reply to message #50154] |
Mon, 20 August 2018 08:43   |
 |
mirek
Messages: 14261 Registered: November 2005
|
Ultimate Member |
|
|
Giorgio wrote on Thu, 09 August 2018 14:34
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?
Unfortunate... really unfortunate.
Either you can consider to fill the table NOT USING Query and set line color as you add rows. In that case, it is possible that you will rather want to use ArrayCtrl instead.
Or you can AddIndex to store the value that you wish to use for the color, then either setup Display based on the index or just test this index in ColorLines.
Depends on what is in "IsAvailable"...
Quote:
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?
Yeah, that is not right approach. Just use .Get(i, 0) - primary key is by definition always the first index.
Mirek
|
|
|
Goto Forum:
Current Time: Mon Jun 09 10:11:13 CEST 2025
Total time taken to generate the page: 0.04601 seconds
|