CellBoldAt

I must be missing something pretty obvious because I cannot get CellBoldAt to work !!!

I have a ListBox that lists our open cases - some have Service Dates in the past, some in the future, and some for the current date. I want to mark the cases with Service Dates = the current date as Bold. The code I’m using is:

While NOT rs.AfterLastRow

lb.AddRow()
lb.RowTagAt(lb.LastAddedRowIndex) = rs.Column(“ClientNum”).StringValue

For i As Integer = 0 to rs.LastColumnIndex - 1

lb.CellTextAt(lb.LastAddedRowIndex,i) = rs.ColumnAt(i+1).StringValue

If rs.Column("TestDate").Value = d.DayOfYear Then
  lb.CellBoldAt(lb.LastAddedRowIndex, i) = True
End If

Next i

rs.MoveToNextRow

I’ve stepped through the code and the IF statement is triggered when the DayOfYear of TestDate = d.DayOfYear. However, the ListBox cells are not showing as Bold.

I’ve tried filling the data in the ListBox row both before and after the CellBoldAt is triggered, but the text is still not Bold.

Any ideas as to what obvious thing I’m overlooking ???

I’m guessing, but I think your reference to rs.Column("TestDate") does not line up with the table cell at lb.CellBoldAt(row, index), so you might be bolding the wrong cell.

Your If statement should include matching i with the column index where you keep your “TestDate” column (and then cast that value to DateTime and do the d.DayOfYear comparison) - so the row & column parameters in your If statement match the parameters in the CellBoldAt(row, column) assignment method.

Scott, actually, I’m looking to Bold every cell in the row where the TestDate = today.

So, “TestDate” only has an integer (28 for today) and not a complete date? (365 for 12/30/2024 for example)

Maybe TestDate is a calculation resulting on the DayOfYear to match the d.DayOfYear?

I can’t find anything else. What Xojo version? What OS?

Works fine, look:

Used code:

Emile, Yes, I understand, as I conducted the same type of test - which is why I reached out to the Forum to figure out if there was something in my code that prevented the Bold.

The response from Scott C (concerning the matching of the RowSet record with the ListBox column has got me thinking, but I haven’t had the chance to test some options that comport with Scott’s adive.

Thanks for your input.

Problem solved - the issue was Operator Error (mine) !!!

In the PaintCellText event of the ListBox I had a “g.Bold = False” entry !!!

That’ll do it every time !!!

Thanks everyone.

1 Like

But you do not say so in your original message. I understand it as (nearly) “setting a Cell contents to Bold does not works”.

Hmmm, perhaps in your OP you should have posted the entire code from your PaintCellText event handler.

2 Likes