-1

I need to show the amount value seperated by ,

For example, my textbox vaue is 614000 and I would like to show in in a textbox like 6,14,000

I wrote the following code

double result = 0;
foreach (DataGridViewRow row in dataGridView1_newww.Rows)
{
    result += Convert.ToDouble(row.Cells["Total_Cost"].Value);
}
textBox1.Text = result.ToString();

but i will not separate directly shows join value = 614000

Mario
  • 35,726
  • 5
  • 62
  • 78
Vaibhav Deshmukh
  • 183
  • 1
  • 11
  • `6,14,000` is not a proper representation for a cost value. Is your pattern always should be as `X,XX,XXX`? – Soner Gönül Aug 05 '15 at 06:55
  • Have a look at this similar stackoverflow question, it shows the formating options available [link](http://stackoverflow.com/questions/105770/net-string-format-to-add-commas-in-thousands-place-for-a-number) – sundeep Aug 05 '15 at 06:59
  • Please give your question a proper title, I tried to edit it a little bit to make it a bit clearer but its still unclear what you are asking, How is the code you provided currently supposed to do custom formatting? – Sayse Aug 05 '15 at 07:00
  • My textbox values shows=614000 but i need or show like 6,14,000 because this is amount – Vaibhav Deshmukh Aug 05 '15 at 07:03
  • Well yes, it would do. that sounds like the default formatting is working. What have you researched to solve your problem? There are plenty of resources around for formatting numbers.. – Sayse Aug 05 '15 at 07:04

1 Answers1

0

try this

String.Format("{0:#,###,###.##}", result)

this will give you commas at the relevant points.

vakeel
  • 287
  • 2
  • 7