C++ .net 浮动到 System::String^

C++ .net float to System::String^

嗨,我发现当我从 mySQL 数据库访问一个浮点值并将其转换为 System::String^ 然后它改变例如 3.153,15 但我想要它输出 3.15 我该怎么做。这是代码:

DataGridViewRow^ row = gcnew DataGridViewRow();
row->CreateCells(this->dataGridView1);
row->Cells[3]->Value = myReader->GetFloat(3);
this->dataGridView1->Rows->Add(row);

我也测试过: row->Cells[5]->Value = ("%f",myReader->GetFloat(5)); 但它仍然给我一个带小数点分隔符逗号的数字,但我想要一个点。

试试这个:

using namespace System::Globalization;

row->Cells[3]->Value = myReader->GetFloat(3).ToString(CultureInfo::InvariantCulture);