LIST BOX - He doesn't order

What you think about this screen shot:

The Column Netto F. is sorted (perfectly sorted)… without code. And so can be the other Column (Lordo F.).

I used “√” instead of True; I do not recall what accountant use to say “Paid !”… If the Field holds False, nothing appears in that Cell. (this design can evolve).

The dates are to be “finished”…

May I suggest using a Tick String as a Constant as it appears properly in macOS/Windows/Linux plus Web and iOS, and looks better than a square root symbol:

Protected Const Tick as String = ✔

I think it’s sorted well :slight_smile: I need to try sorting the query on the table again, without using RowComparision.

I will share the poject to you soon (tomorrow ?)

Yes, thank you.
My query is this:

dim StringaDiOrdinamento as string
StringaDiOrdinamento="TotaleScadenza"
rows = db.SelectSQL("SELECT * FROM Scadenziario  order by "+StringaDiOrdinamento)

and I get the data sorted in the wrong way.
I’m definitely wrong, but I don’t understand where.

you can’t have both columns sorted at the same time.

I’m not sorting both columns at the same time, but just asking the query to sort the data by TotalExpiration. Or am I wrong?

No. But the ORDER BY command made an alphabetically sort, exactly what you get/don’t want.

Sorry, I have to go right now.

What is the CREATE TABLE used to make the Scadenziario table? What type have you given TotaleScadenza ?

Good morning TIM, I don’t remember where CREATE TABLE is, however Scadenziario is a table with a series of data, I tried to sort the table based on the Total (€) column on the ListBox, which in the MsAccess database table is called TotaleScadenza and is of the Currency type. Sorting the table with the commands written above, it is not sorted well… in fact 103.70 is ordered, then there is 1073.60, then 109.80 …etc…etc…
I managed to do the good sorting, writing the code inside RowComparision and everything is sorted perfectly, but Emile had suggested to me that simply by setting an ORDER BY in the query, I could get the same result with less code … but the sorting doesn’t work and I can’t explain why.
Is there a problem sorting the data with …“Scadenziario order by TotaleSacdenza” ?? Is it the type of data that is annoying?

Unfortunately, as I discovered, not for Currency data.

It’s because of the comma (decimal separator).
In reading the currency column, try to use:

Out of the reading loop:
Var ital As New Locale("it-it")

In the reading loop, when you want to read currency values
LB.CellTextAt(LB.LastAddedRowIndex,2) = row.Column("NettoF").CurrencyValue.ToString(Ital)

LB is a reference to a DesktopListBox
NettoF comes from your first screen shot.

With that, I get the real values on screen (2,15 € for example), and they are sort fine with the default DesktopListBox sort feature.

I tried to load the data as suggested, but the sorting by clicking on the column concerned, however, gives me the wrong one.
The second table, however, with the sorting algorithm in RowCompariosion, works.

At this point, I give up, I use the sorting algorithm in RowComparition.

That is the correct solution.

1 Like