Is there a way to align a column to Left AND align the header of this column to Right
This code align all the 4th column but I need a different alignement for the header of the 4th column
me.ColumnAlignmentAt(3) = Listbox.Alignments.Right
Is there a way to align a column to Left AND align the header of this column to Right
This code align all the 4th column but I need a different alignement for the header of the 4th column
me.ColumnAlignmentAt(3) = Listbox.Alignments.Right
No, there isn’t. And AFAIK, not even piDog’s DataViewer or GraffitiListbox offering it.
Remove Xojo Header and set your own…
Or… draw the text in the Header Text Paint Event…
This has actually already been added for the next release by request of another user. If a user with an active Desktop Edition subscription wants the update, they just need to open a ticket and request it and I’ll take care of it when I get in late tonight.
Dataview also has this functionality. You can set it in the ListColumn object…
dim lc as piDogDataView.ListColumn = me.Column(0)
lc.HeadingAlignment = piDogDataView.DataView.AlignmentRight
me.Column(0) = lc
There’s quite a few other options in ListColumn as well.
Documentation on PaintHeaderContent is very short, anyone can post a code snippet ?
https://documentation.xojo.com/api/user_interface/desktop/desktoplistbox.html.PaintHeaderContent
Is this what you want?
That is the code I used:
Function PaintHeaderBackground(g As Graphics, column As Integer) As Boolean
g.DrawingColor = Color.White
g.FillRectangle 0, 0, g.width, g.height
return true
End Function
Function PaintHeaderContent(g As Graphics, column As Integer) As Boolean
Var t As String = "hello world "
Var x As Double = g.TextWidth(t)
g.DrawingColor = color.black
g.DrawText t, g.width-x, g.FontAscent
Return True
End Function
what is the problem? the only problem is to take care about cell alignment when adding value/row:
Listbox1.HeaderAt(0)="column name"
Listbox1.ColumnAlignmentAt(0)=DesktopListBox.Alignments.Right
Listbox1.AddRow "test value"
Listbox1.CellAlignmentAt(0,0)=DesktopListBox.Alignments.Center
Thank you, it’s work fine . The real question is why you can not change the header alignement after adding rows ?
…because there is no property to change the alignment of header only. If you set column alignment after adding rows - it will reset alignment for whole column.