0

I am filling dataGridView with data selected from MySQL table with this code

MySqlConnection sqlConnection = new MySqlConnection(sqlParams);

try
{
    MySqlDataAdapter adapter = new MySqlDataAdapter();
    adapter.SelectCommand = new MySqlCommand(sqlQuery, sqlConnection);

    DataSet ds = new DataSet();
    adapter.Fill(ds);
    dataGridView1.DataSource = ds.Tables[0];
    dataGridView1.Sort(dataGridView1.Columns["ColumnName"], ListSortDirection.Ascending);
}
catch {
}

And one of the columns contains sum data (for example 10.34 USD), but problem is what in my country format it must be "10,34" (coma instead of dot), so i want to change this sign while filling dataGridView to proper one. Is it possible? Or is there another methods? Because now i am storing sums in "dot" format because so i can use MySQL commands like SUM.

In short: in MySQL i have 10.34, but user must see 10,34 :)

4

1 に答える 1

1

はい、可能です。フォーマットは datagridview で設定できます。

dataGridView1.Columns["ColumnName"].DefaultCellStyle.Format = "C";

「C」は、通貨の書式設定を意味します。「N」は、一般的な数値の書式設定用です。また、国固有のフォーマットについては、現在のスレッドの特定のフォーマット プロバイダーを設定できるクラス CultureInfo を使用できます。

于 2013-03-11T21:49:09.767 に答える