Is it possible to have more than 1 text line in a listbox header column ?
instaed of ‘Date Created’
I would like to have in 1 header column displayed
- line: ‘Date’
- line: ‘Created’
since we can change listbox header height, we should be able to display multiple lines in a listbox header column …
Yeah, you can do this with the
HeaderContentPaint-Event. You have to split the lines by yourself.
thanks Martin, I’ll try it
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!
You can set the Header Height in Xojos Listbox using 2020+.
I have tried this in HeaderContentPaint
If column = 0 Then
g.DrawText ( “1.Line”, 0, 0 )
but this displays nothing, header is empty
The location is wrong. You need to change the second 0 to the height of the font or more.
I know, Martin … that’s why I said “If you’ve got Xojo 2020r1 or better, refer to this Xojo Blog article” … but thanks anyways!
That works, text displayed but is hard to read, almost the same colour as background
had to set the text colour
how can I center the text ?
Check out DrawingColor: https://documentation.xojo.com/api/graphics/graphics.html#graphics-drawingcolor.
For centering you need to know the StringWidth:
Private Function getStringWidth(theString as String) as Integer
dim thePicture as new Picture(500, 100, 32)
thePicture.Graphics.FontSize = NSFontMBS.SystemFontSize
Then you can calculate where to draw the text.
Drawing multiline code centered is a bit more work.
I though it should be easy, now it turns out to be complicated, I will stay with my own listbox header object.