View previous topic :: View next topic |
Author |
Message |
amsimmon
Joined: 31 Mar 2006 Posts: 13
|
Posted: Fri Mar 31, 2006 11:10 pm Post subject: Column Format causes blow-up |
|
|
I have a tree bound to objects. One of the fields in the object is a decimal that I want to display as currency. I went to the databinding and set the Format property on the field. If I set it ${0} it works ok, putting a dollar sign in front of the number but with the wrong number of decimal places. If I set it to ${0.00} as suggested in the documentation it blows up with this exception:
************** Exception Text **************
System.FormatException: Input string was not in a correct format.
at System.Text.StringBuilder.FormatError()
at System.Text.StringBuilder.AppendFormat(IFormatProvider provider, String format, Object[] args)
at System.String.Format(IFormatProvider provider, String format, Object[] args)
at Infralution.Controls.VirtualTree.CellData.GetText()
at Infralution.Controls.VirtualTree.CellWidget.get_Text()
at Infralution.Controls.VirtualTree.CellWidget.PaintText(Graphics graphics, Style style, Boolean printing)
at Infralution.Controls.VirtualTree.CellWidget.PaintForeground(Graphics graphics, Style style, Boolean printing)
at Infralution.Controls.VirtualTree.CellWidget.OnPaint(Graphics graphics)
at Infralution.Controls.Widget.OnPaint(Graphics graphics)
at Infralution.Controls.VirtualTree.RowWidget.OnPaint(Graphics graphics)
at Infralution.Controls.Widget.OnPaint(Graphics graphics)
at Infralution.Controls.WidgetControl.PaintWidgets(Graphics graphics, Rectangle clipRectangle)
at Infralution.Controls.WidgetControl.OnPaint(PaintEventArgs e)
at Infralution.Controls.VirtualTree.VirtualTree.OnPaint(PaintEventArgs e)
at System.Windows.Forms.Control.PaintWithErrorHandling(PaintEventArgs e, Int16 layer, Boolean disposeEventArgs)
at System.Windows.Forms.Control.WmPaint(Message& m)
at System.Windows.Forms.Control.WndProc(Message& m)
at Infralution.Controls.BorderedControl.WndProc(Message& m)
at Infralution.Controls.VirtualTree.VirtualTree.WndProc(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam) |
|
Back to top |
|
|
Infralution
Joined: 28 Feb 2005 Posts: 5027
|
Posted: Sat Apr 01, 2006 9:23 am Post subject: |
|
|
Try the format string: "${0:0.00}"
The first zero is a placeholder for the parameter being formatted. The part after the colon is the format for the parameter. _________________ Infralution Support |
|
Back to top |
|
|
amsimmon
Joined: 31 Mar 2006 Posts: 13
|
Posted: Mon Apr 03, 2006 3:36 pm Post subject: |
|
|
That works, thanks!
I'm using the string below in the Format property to get the default system currency display:
{0:C}
The Virtual Tree documentation page for CellBinding.Format had the string that doesn't work. |
|
Back to top |
|
|
Infralution
Joined: 28 Feb 2005 Posts: 5027
|
Posted: Mon Apr 03, 2006 10:15 pm Post subject: |
|
|
Thanks you are right that's a typo in the documentation which we will fix. _________________ Infralution Support |
|
Back to top |
|
|
|