New topic: 

Applying color to text in a listbox

<http://forums.realsoftware.com/viewtopic.php?t=29703>

       Page 1 of 1
   [ 1 post ]                 Previous topic | Next topic         Author  
Message       martinpaulrice           Post subject: Applying color to text in 
a listboxPosted: Sun Aug 23, 2009 2:52 pm                        
Joined: Wed Apr 11, 2007 1:17 pm
Posts: 34              Hi,
I've done a lot of searching on the forum but have not come across what I think 
is the real answer to my question/problem. It might be there, but I haven't 
been able to recognize it.

Here's the problem: I'm populating a 5-column listbox from a table -- only four 
columns are and need to be visible. The fourth column is formatted at currency. 
In addition, based on the text value in the first column, I want some of those 
figures in the fourth column to be in red.

I have no problem doing this in editfields, but I just can't figure out how to 
do it in the listbox. I've tried many things but they don't work. For example, 
this is my latest fiasco:

 Code:else
// Populate the listbox with the budget account data

Dim bAB As String
Dim r As Color
r = RGB(255,0,0)

while not rs.eof
  lbBudget.AddRow(rs.Field("BudID").StringValue)
  lbBudget.Cell(lbBudget.LastIndex, 1) = rs.Field("BudAcctType").StringValue
  lbBudget.Cell(lbBudget.LastIndex, 2) = rs.Field("BudAcctName").StringValue
  lbBudget.Cell(lbBudget.LastIndex, 3) = rs.Field("BudAcctBal").StringValue
  
  // Now change amount to red if an Expense Account
  // First see if it's an expense and if so, change the color to red
  
  If rs.Field("BudAcctType").StringValue = "Expense" then
  fldColorChange.Text = rs.Field("BudAcctBal").StringValue
  fldColorChange.TextColor = r
  lbBudget.Cell(lbBudget.LastIndex, 3) = fldColorChange.Text
  fldColorChange.Text = ""
  End if
  
  
  // Now Format the Budgeted Amount and insert into ListBox
  bAB = lbBudget.Cell(lbBudget.LastIndex, 3)
  bAB = Format(val(bAB), "\$###,##0.00")
  lbBudget.Cell(lbBudget.LastIndex, 3) = str(bAB)
  bAB = ""
  
  rs.MoveNext
wend

  
In this desperate example I tried to change the color in an invisible field 
(fldColorChange), but when it's then written back to the proper listbox cell 
it's in black. I realize that it won't work this way when I then format the 
number, but I've had the formatting code commented out and just tried the color 
code section and that doesn't work.

I'd really appreciate being aimed in the right direction.

Thanks!     
_________________
Martin
Signal Mountain, TN  
                            Top           Display posts from previous: All 
posts1 day7 days2 weeks1 month3 months6 months1 year Sort by AuthorPost 
timeSubject AscendingDescending          Page 1 of 1
   [ 1 post ]     
-- 
Over 1500 classes with 29000 functions in one REALbasic plug-in collection. 
The Monkeybread Software Realbasic Plugin v9.3. 
http://www.monkeybreadsoftware.de/realbasic/plugins.shtml

[email protected]

Reply via email to