Does not order data with format ##, ## 0.00 VB.NET

2

I have an application that makes some calculations and I save them in a datagridview, to a column I give the currency format in this way: Format(totalMarca, "##,##0.000") So far so good, but I try to sort the data and do not do it. The following image shows the data after sorting them Ascending. I thought I was doing the ordering algorithm wrong but now I try to sort the data with the default option of the DataGridView and I get the same detail. It should be clarified that if I do not format the data if I order them correctly .. Any suggestions?

    
asked by Silvestre Silva 27.03.2018 в 17:43
source

1 answer

3

Solved the problem:

When I register the sum, I do it without format:

DataGridView1.Rows.Add(marca, totalMarca)

and already at the moment of interacting with the form where it contains the dataGridView I do the ordering:

DataGridView1.Sort(DataGridView1.Columns(1), System.ComponentModel.ListSortDirection.Descending) 

and the last one I format.

DataGridView1.Columns(1).DefaultCellStyle.Format = "$ #,##0.00"
    
answered by 27.03.2018 / 19:04
source