WebListbox Row Swap

I’ve noticed that my listbox sort method almost works.
All the data gets sorted correctly, but row tags, selections, styles may not be being ‘swapped’ and so things end up looking wrong.

Anyone care to give some advice on how to make sure all the row attributes get swapped?
Introspection?

It would be helpful to see your column sort code.

Here she blows!

[code]Private Sub DoSort(onColumn as Integer, order as sortOrder)
dim columnContents(-1) as string
dim sortWith(-1) as integer
dim r,c as integer

if onColumn < ColumnCount and onColumn >= 0 then

for r=0 to RowCount-1
  columnContents.Append cell(r, onColumn)
  sortWith.Append r
next
columnContents.SortWith(sortWith)

for c=0 to ColumnCount-1
  redim columnContents(-1)
  
  for r=0 to RowCount-1
    columnContents.Append cell(r, c)
  next
  
  if order = SortableWebListBox.sortOrder.ascending then
    
    for r=0 to RowCount-1
      cell(r, c) = columnContents(sortWith(r))
    next
    
  else
    
    for r=0 to RowCount-1
      cell(RowCount-r-1, c) = columnContents(sortWith(r))
    next
    
  end if
  
next

end if

System.DebugLog(“Lets See.”)

End Sub
[/code]

Oh, so you really are just sorting the column.

In that first loop, just append the rowtags to an array of variant and add the array to the end of the sortwith statement.

FWIW, Why not just requery your datasource and repopulate the rows that way? It would probably be just as efficient, if not more-so.

[quote=397892:@Greg O’Lone]Oh, so you really are just sorting the column.

In that first loop, just append the rowtags to an array of variant and add the array to the end of the sortwith statement.

FWIW, Why not just requery your datasource and repopulate the rows that way? It would probably be just as efficient, if not more-so.[/quote]

That’s helpful. Thanks. but I think there are a lot of other attributes that might need to be copied… like cell backgound colors etc.

that is what i always do… unless user click on the column heading of the listbox, i use CompareRow with a subroutine that check if it is date, amount, number or just text and sort appropriately