DeskTop ListBox Printing - Converting from previous ListBox

I am in the process of converting a desktop application Listbox to DesktopListBox print routine.

In this code and the lines with

w = source.ColumnAt(i).widthActual * scale

are what I am having trouble solving a conversion for. Any suggestions on how to make this conversion work for newer Desktop-ListBox?

Var mytext as string
Var w, height, maxH as integer
Var sx, sy, offset as integer
Var i as integer

if not source.HasHeader then return 0

redim xs(-1)

g.FontName=source.FontName
g.FontSize= 10 'source.FontSize

headerHeight = DrawHeader(g) + 20
sy = headerHeight

For i=startRow To source.columncount-1
  
  mytext = source.HeaderAt(i)
  w = source.ColumnAt(i).widthActual * scale
  height=g.TextHeight(mytext,w)
  
  If g.textheight>height Then height=g.textheight
  
  If height>maxH Then maxH=height
  
  offset=3
  
  If w>g.TextWidth(mytext)*scale Then
    offset=w/2-g.TextWidth(mytext)*scale/2
  End
  
  If source.ColumnAt(i).WidthActual <> 0 Then 
    g.DrawText mytext,sx+offset,g.FontAscent + sy, w
  End
  
  xs.AddRow sx
  sx=sx+w
  
Next

// This sets how far down our horizontal line is drawn after the header
g.DrawingColor=lineColor
g.drawline 0,headerHeight + sy, g.width,headerHeight + sy
g.DrawingColor=textcolor

return headerHeight + sy

??For i=startRow To source.columncount-1?? doesn’t seem right to me.

What is startRow

Should it be column 0 to columncount -1:

For i=0 to source.columncount-1

I think you’re looking for

w = source.ColumnAttributesAt(i).WidthActual * scale

This is a Method with these parameters passed in
startRow as integer, g as graphics, scale as single, byref xs() as integer

And this as a return type
integer

@Tim_Hare

Thats it - thank you very much

Carl