Numbers with red text in DataGrid cell
Posted: Mon Oct 06, 2014 11:08 pm
This has me stumped now but I have done it before with code very similar to what I show below. Can anyone spot why this is not working?
I have a datagrid with 33 columns where the even numbered rows contain basically just text while the odd rows contain mostly 'numeric' values even though the column itself is set for text format. Under certain conditions I want the 'numeric' text to show up red while all the other text is black. I am using the FillnData routine that is in my button called My Default Column Behavior to accomplish this. Here is partial code for that button:
The columns in question are called Pick1,Pick2, Pick3, ... Pick30 and there also ia a column called Average that may need to me made red. There is a global variable called Liquidity that is compared to the 'numbers' in those columns that determines when the I want the color red. In the code I have an if condition (would not normally be included) that lets me insert a breakpoint to stop when I get to the last column. When I get to that point, the cells that are supposed to contain red text do contain red text. When I step slowly and finish the FillnData routine the next step puts me back in the FillnData routine for the next row od data but the line I just finished is now all black.
Is there some datagrid setting I am missing? Why is it changing back. The other situations where I have used FillnData to change the color of the text have not involved a global variable nor the alternating rows.
Thanks for any light you can shed on this,
Larry
I have a datagrid with 33 columns where the even numbered rows contain basically just text while the odd rows contain mostly 'numeric' values even though the column itself is set for text format. Under certain conditions I want the 'numeric' text to show up red while all the other text is black. I am using the FillnData routine that is in my button called My Default Column Behavior to accomplish this. Here is partial code for that button:
Code: Select all
-- This message is sent when the Data Grid needs to populate
-- this template with the column data. pData is the value to be displayed.
--set the text of the long ID of me to pData ## temp workaround for
global gLiquidity
put the dgColumn of me into tCol
If tCol="Pick30" then
beep
end if
if offset("Pick",tCol)>0 then
put "Pick" into tCol
end if
switch tCol
case "Pick"
if isNumber(pData) then
set the numberFormat to "#.0000"
put pData*1 into pData
if pData > gLiquidity then
set the foreGroundColor of me to "red"
end if
end if
break
case "Average"
set the numberFormat to "#.0000"
put pData*1 into pData
if pData > gLiquidity then
set the foreGroundColor of me to "red"
end if
break
end switch
set the text of the long ID of me to pData ## temp workaround for
end FillInData
Is there some datagrid setting I am missing? Why is it changing back. The other situations where I have used FillnData to change the color of the text have not involved a global variable nor the alternating rows.
Thanks for any light you can shed on this,
Larry