I used an “old” method to resize the columns in a ListBox. I tried to convert this existing method to Xojo Version 2023 release 1.1.
// Change Column Widths
Var p As New Picture(10,10)
Var g As graphics = p.Graphics
Var CellWidth as Integer
Var ColumnSize as Integer
g.FontName = Me.FontName
g.FontSize = Me.FontSize
for Column As Integer = 0 to Me.ColumnCount-1
ColumnSize = g.TextWidth(Me.HeaderAt(Column))
for Row As Integer = 0 to Me.LastRowIndex
CellWidth = g.TextWidth(Me.CellTextAt(Row, Column))
if CellWidth > ColumnSize then
ColumnSize = CellWidth
End If
next Row
Me.ColumnAttributesAt(Column).WidthActual = ColumnSize + 20
next Column
No errors found… But no resizing… What is wrong with this code?
Sorry folks… My code is just perfect. The header of the DesktopListbox was not yet initialized before the method was started. This piece of code works well to resize a DesktopListbox based on het headers and data in the columns.
I do not found it so usefull: too near API2. Code taken from there does not compile in Xojo 2015…
And when you have a MacBook Pro i5 / code with MacBook Pro m1…