List Heading font, size, etc

I have a Mac app, with a ListBox, with a Heading. On the ListBox OPEN, I set a custom font, size, etc. In the past (prior to the last 2014 Xojo release), my ListBox AND its heading had the desired custom font, size. But, since the last 2014 release and the first 2015 release, now only the ListBox proper has my desired font and size. The ListBox heading is NOT showing my chosen customizations. Something’s changed! Anyone have a clue? THANKS!

Wasn’t the last release in 2014 when Carbon was dropped and you had to compile for Cocoa? That could be it…

Thanks Bill. Good thought, but I don’t think so. This app has been Cocoa for a long time. I’m just not sure if (or where) I’m doing something wrong, or if the last release or two changed how the heading of a listbox is handled (all within Cocoa)?

I could be wrong, but I don’t recall specific control over the font info of the heading. The few times that I have needed this, the way I did it was set the Grid’s font to whatever I wanted the header, then in the CellTextPaint event handler set the graphics object to want I want the rest of the grid to look like:

g.TextFont = “System”
g.TextSize = 10
g.Bold = False
g.Italic = False

Thanks Merv. Well, I wanted all the lines of the ListBox as well as its top-most Heading line to be the same as each other, but different from a default size. So, in the OPEN event of the ListBox, I set the font and size to what I wanted. (Shouldn’t that, as before, cover ALL the lines in the ListBox?) But, now that seems to handle only the regular Listbox lines NOT the Heading line. I wonder if this is a just discovered bug? Maybe no one else noticed??

Works here on Windows in the current version (r1b8 actually). New project with one ListBox on Window1. This is in the open event of the ListBox1:

Me.TextFont = “Arial”
Me.TextSize = 18
Me.Italic = True

Me.AddRow
Me.AddRow
Me.AddRow

Me.Cell(1,1) = “Test”

seems to do what I expect.

Thanks Merv. Appreciate the test. That’s a bit of a mystery though. I also have the text font and size changes in the OPEN event but the Heading doesn’t get the new fonts and size choice, (but the other lines do.). Are you sure you have the HasHeading property as true, and put text into both the heading and a regular line or two?

Yes, HasHeading is set to true. Tried it both ways setting it in the IDE and then turning that off and setting it in the Open even. Either way works as expected. This is my open event now:

Me.TextFont = “Arial”
Me.TextSize = 18
Me.Italic = True

Me.AddRow
Me.AddRow
Me.AddRow

Me.HasHeading = True
Me.Heading(1) = “My Header”
Me.Cell(0,0) = “Test”
Me.Cell(1,1) = “Test”

everything else in the ListBox is whatever gets set when it is placed on Window1.

Thanks again Merv. I can’t explain it…yet. Near as I can tell here, I’ve made ZERO changes to this particular code in question since before the last Xojo 2014 release. Yet suddenly when recompiling this app with the last two releases, my ListBox Header font/size are no longer correct. When that happens (without my changing my own code), I think that Xojo changed something without my knowing about it (wouldn’t be the first time I missed something.) It might be subtle, maybe they changed the order of events, or when HasHeading property is set programmatically maybe it re-defaults it to standard font/size instead of previously customized fonts size. I just don’t know. Maybe I have to intercept the writing of the header line and re-specify the font/size?? Just don’t know. Again, I thank you for your test. I’ve got some more thinking/testing to do on my own.

Hi again Merv. Still with me. Hope so…if so, you might try this. Create a test mac (or presumably Windows) project, just add a ListBox to the window, add an OPEN event for the ListBox, and insert this code…

Me.HasHeading = True

Me.TextFont = “Arial”
Me.TextSize = 18
Me.Italic = True

Me.Heading(0) = “My Header”
Me.AddRow(“One”)
Me.AddRow(“Two”)
Me.AddRow(“Three”)

When I do this (as with my actual app), I find that “My Header” is in some default font and size, but the ONE TWO and THREE lines are correctly my customized Arial and 18.

Don’t you think the Heading should also be Arial and 18? I do. That’s how it was back before the last 2014 Xojo release. Now, with the last 2014 Xojo release, and the first 2015 release, the Heading no longer shows the customized font and size setting?

(I’m glad, thanks to your sample code which got me started, that I now at least have a very small snippet of code that can demonstrate either this bug, or my misunderstanding of how such code should really be written??)

On Windows it works. On the Mac it is Arial 18 italicized, but the Header is still same physical height and very cramped. That part could be a bug, but as far as the Font and FontSize goes, it seems correct. Wish I could be of more help, but I have deadline this weekend, so I have to get back on the my project. You should probably talk to Xojo at this point.

Righto! Thanks Merv!

Did you ever get an answer to this? I’m trying out the latest (2017r1) Xojo for a warehouse display that requires a large font, and, well, I can’t ship this…

here is a custom class I wrote years ago to solve this exact problem

www.rdS.com/lb_header.zip

it “attaches” to a listbox and acts as a customizable header… source code is included so you can adapt it as you see fit

donations appreciated :slight_smile:

and yes it does work with latest Xojo… I installed it in my latest project over the weekend :slight_smile:

added an example above :slight_smile:

once attached… the custom header automagically uses the metrics from the listbox (font, row height etc)…

And here is my version of a similar control to Dave’s:

ListBoxHeading.rbo