I see your code is converting numeric currency values to a string and then displaying the string in the DataGridView
- that's your problem: this means the DataGridView will be performing lexicographic-ordering on the strings instead of numerical ordering (i.e. "21"
is ordered after "123"
because '2' > '1'
.
I don't know what the definition of m_DataRow
is, but it smells like you're using untyped DataSets, or perhaps a crudely created typed-DataSet but without any meaningful column names and types.
Unfortunately because your DataGridView looks to be bound to this m_dataRow
object you're stuck unless you can recreate it correctly (e.g. with actual column names and types). However if you're using untyped DataSets then just change your code to stop formatting currency values to string but instead provide the raw Decimal
value directly, and then use DataGridView's own column formatting to specify the "C" (for currency) format string.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…