8 Replies - 77806 Views - Last Post: 18 January 2012 - 10:44 AM Rate Topic: -----

#1 webwired  Icon User is offline

  • D.I.C Regular
  • member icon

Reputation: 33
  • View blog
  • Posts: 339
  • Joined: 26-August 07

how to format datagridview single column to currency

Post icon  Posted 01 September 2007 - 06:55 AM

Hi, I was wondering if anyone knew how to make a single column of a datagridview into currency format?

			InventoryDataGridView.Columns(5).Name = "inventory_cost"
			InventoryDataGridView.Columns(5).DataPropertyName = "inventory_cost"
			InventoryDataGridView.Columns(5).Width = 70
			InventoryDataGridView.Columns(5).HeaderText = "Cost"
			InventoryDataGridView.Columns(5).???


This post has been edited by webwired: 01 September 2007 - 06:57 AM


Is This A Good Question/Topic? 0
  • +

Replies To: how to format datagridview single column to currency

#2 PsychoCoder  Icon User is offline

  • Google.Sucks.Init(true);
  • member icon

Reputation: 1639
  • View blog
  • Posts: 19,853
  • Joined: 26-July 07

Re: how to format datagridview single column to currency

Posted 01 September 2007 - 07:06 AM

Try this out
]
String.Format("{0;c}", InventoryDataGridView.Columns(5).ToString)


Was This Post Helpful? 0
  • +
  • -

#3 webwired  Icon User is offline

  • D.I.C Regular
  • member icon

Reputation: 33
  • View blog
  • Posts: 339
  • Joined: 26-August 07

Re: how to format datagridview single column to currency

Posted 01 September 2007 - 07:27 AM

It gave me this

Input string was not in a correct format.
Was This Post Helpful? 0
  • +
  • -

#4 PsychoCoder  Icon User is offline

  • Google.Sucks.Init(true);
  • member icon

Reputation: 1639
  • View blog
  • Posts: 19,853
  • Joined: 26-July 07

Re: how to format datagridview single column to currency

Posted 01 September 2007 - 07:44 AM

For starters I got it wrong (damn semi-colons lol)

String.Format("{0:c}", InventoryDataGridView.Columns(5).ToString)


Was This Post Helpful? 0
  • +
  • -

#5 webwired  Icon User is offline

  • D.I.C Regular
  • member icon

Reputation: 33
  • View blog
  • Posts: 339
  • Joined: 26-August 07

Re: how to format datagridview single column to currency

Posted 01 September 2007 - 08:06 AM

LOL... Actually it didn't change anything at all.
Was This Post Helpful? 0
  • +
  • -

#9 webwired  Icon User is offline

  • D.I.C Regular
  • member icon

Reputation: 33
  • View blog
  • Posts: 339
  • Joined: 26-August 07

Re: how to format datagridview single column to currency

Posted 01 September 2007 - 08:46 AM

Got it...

Me.InventoryDataGridView.Columns(5).DefaultCellStyle.Format = "c"


Was This Post Helpful? 1

#10 PsychoCoder  Icon User is offline

  • Google.Sucks.Init(true);
  • member icon

Reputation: 1639
  • View blog
  • Posts: 19,853
  • Joined: 26-July 07

Re: how to format datagridview single column to currency

Posted 01 September 2007 - 09:10 AM

Whoops :blush: forgot about the DefaultCellStyle Property, sorry
Was This Post Helpful? 0
  • +
  • -

#11 Guest_Amin Parsi*


Reputation:

Re: how to format datagridview single column to currency

Posted 25 May 2010 - 11:37 AM

Hi guys,
I use this format: (1000000 -> 1,000,000)

Format = "##,0"

Me.InventoryDataGridView.Columns(5).DefaultCellStyle.Format = "##,0"


Good Luck.
Was This Post Helpful? 0

#12 deepak_program  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 5
  • Joined: 02-July 07

Re: how to format datagridview single column to currency

Posted 18 January 2012 - 10:44 AM

Use CultureInfo

example for Indian Format

Me.InventoryDataGridView.Columns(5).DefaultCellStyle.Format = String.Format("n",System.Globalization.CultureInfo.CreateSpecificCulture("hi-IN"))


Was This Post Helpful? 0
  • +
  • -

Page 1 of 1