Hi everybody,
I would like to know how to set cell's data as a double that contains a "." (point instead of comma ","). In my program I read a file that contains doubles (with points i.e. "5.1"), but when I try to load it to cells it automatically converts all points to comma (i.e. "5,1"), and I don't want that, I would like to conserve the same format (so in this case "5.1"). N.B: For me it's not necessary to load the numbers as double variable (maybe using a string or ...). My code is like that:
Code Snippet
double number1,number2,number3,number4,number5,number6,number7;
fstream f1; f1.open(str1,ios::in); for(int i=0;i<n-1;i++){ f1>>number1; f1>>number2; f1>>number3; f1>>number4; f1>>number5; f1>>number6; f1>>number7; dataGridView1->Rows[i]->Cells[0]->Value = number1; dataGridView1->Rows[i]->Cells[1]->Value = number2; dataGridView1->Rows[i]->Cells[2]->Value = number3; dataGridView1->Rows[i]->Cells[3]->Value = number4; dataGridView1->Rows[i]->Cells[4]->Value = number5; dataGridView1->Rows[i]->Cells[5]->Value = number6; dataGridView1->Rows[i]->Cells[6]->Value = number7; } Thank you very much for any help,
| | lixo1 Monday, December 01, 2008 7:49 PM | Hi lixo1,
Try to use Math.Round() or FormatCurrency() or Format() Functions.
Thank You
Best Regards
Utkarsh Gajjar
| | Utkarsh Monday, December 01, 2008 7:53 PM | Hi lixo1,
Here is sample code.
With Math.Round()
Code Snippet dataGridView1.Item(0, 0).Value = Math.Round(45.9067, 2)
With FormatCurrency
Code Snippet dataGridView1.Item(0, 0).Value = FormatCurrency(45.9067, 2)
If any problem let me know.
Thank You
Best Regards
Utkarsh Gajjar | | Utkarsh Monday, December 01, 2008 8:33 PM | Hi lixo1,
Try to use Math.Round() or FormatCurrency() or Format() Functions.
Thank You
Best Regards
Utkarsh Gajjar
| | Utkarsh Monday, December 01, 2008 7:53 PM | Hi Utkarsh, Thank you very much for your help, but could you please give a small example? Thank you another time. Best
| | lixo1 Monday, December 01, 2008 8:26 PM | Hi lixo1,
Here is sample code.
With Math.Round()
Code Snippet dataGridView1.Item(0, 0).Value = Math.Round(45.9067, 2)
With FormatCurrency
Code Snippet dataGridView1.Item(0, 0).Value = FormatCurrency(45.9067, 2)
If any problem let me know.
Thank You
Best Regards
Utkarsh Gajjar | | Utkarsh Monday, December 01, 2008 8:33 PM | Hi Utkarsh, Thank you very much for your help! Now it's perfect! Best, lixo1
| | lixo1 Tuesday, December 02, 2008 11:23 AM |
|