If you’ve got Xojo 2020r1 or better, refer to this Xojo Blog article (" Customize Your ListBox Headers"). You can find it at https://blog.xojo.com/2020/09/08/customize-your-listbox-headers/. AFAIK, any version prior to 2020r1 doesn’t offer you any easy solutions for multi-line headers.
However, I would STRONGLY recommend that you look into investing in piDog Software’s DataView. It does bunches of things that the standard Xojo listbox doesn’t … including allowing the setting of Header Height. I find it infinitely easier to accomplish what I need using DataView (which is advertised as a “direct drop-in replacement” for the Xojo listbox … although I’ve found a few minor exceptions to that). And I think you’ll find DataView priced quite affordably. I’ve gotten to the point where I can’t do without it!
Private Function getStringWidth(theString as String) as Integer
dim thePicture as new Picture(500, 100, 32)
thePicture.Graphics.FontSize = NSFontMBS.SystemFontSize
Return thePicture.Graphics.TextWidth(theString)
End Function
Then you can calculate where to draw the text.
Drawing multiline code centered is a bit more work.