Alright, I have a DataGridView which is being databound like:
dataGridViewChartOre.AutoGenerateColumns = false;
dataGridViewChartOre.DataSource = xml.GetOreChart();
dataGridViewChartOre.DataMember = "ore";
All columns have been created manually via the UI. And the columns consists of 1 string, 10 decimals. Where the last column is a currency.
Now getting a currency to show in the dataGridView was quick to solve once, I remembered that the input from xml was always a string. Using this approach: (Found else where on this sites.)
private void dataGridViewChartOre_CellFormatting(object sender, DataGridViewCellFormattingEventArgs e)
{
string value = e.Value.ToString();
decimal d;
if (decimal.TryParse(value, out d))
{
e.Value = d;
}
}
Now getting, the decimals to sort, seems to of a much bigger problem. I've tried a couple of suggested solutions, however none have worked so far.
- Using float instead of decimals.
- Utilizing the SortCompare // SortResult
Right now, it sorts all the decimals by its first number only, ie:
8616
8225
785995
7833
78069
773403
750268
74521
738249
714541
70972
and so on
So how to fix this, and even better if somebody could explain to me why it does this ?
Also, on a side note, how to change CurrencySymbol? I want to use a different symbol accross the whole program, however, it should retain the regular en-US datetime format.