Resize columns DesktopListbox

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?

This is the syntax:
ColumnAttributesAt(column As Integer, Assigns value As DesktopListBoxColumn)

does not looks the same (to me), but I may be wrong.

The documentation here for desktoplistbox: DesktopListBoxColumn — Xojo documentation
shows this example:

Me.ColumnAttributesAt(0).WidthActual = 80
Me.ColumnAttributesAt(1).WidthActual = 80
Me.ColumnAttributesAt(2).WidthActual = 45

When you say “but no resizing”, what happens if you change:

Me.ColumnAttributesAt(Column).WidthActual = ColumnSize + 20

to (for example)

Me.ColumnAttributesAt(Column).WidthActual = ColumnSize + 100

do the columns change size or not?
Can you check the value of ColumnSize before that line of code? You can put a break maybe ColumnSize = 0?

Can you provide a sample project?

The examples are probably far below ColumnAttributesAt… because there are none there: ColumnAttributesAt

Bad online documentation.

Sorry for the error.

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.

Thank you all!

The documentation is really bad… It takes a long time to find the correct methods, properties…

I usually use https://docs.xojo.com but now that site is going away soon :frowning:

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…