0

I need to display float numerics with symbol "+" or "-" before.

What is the correct string format?

For ex.

-1,5
-1
-0,5
 0
+0,5
+1

  settings.Columns.Add(column =>
          {
              column.FieldName = "current";
              column.Caption = "Numeric";
              column.ColumnType = MVCxGridViewColumnType.SpinEdit;
              var edsettings = column.PropertiesEdit as DevExpress.Web.ASPxEditors.SpinEditProperties;
              edsettings.DisplayFormatString = "0.#";
          });

this is column of devexpress component grid in asp.mvc. where "current" is decimal value in Model

4
  • 2
    Can you post any sample code? Commented Aug 29, 2012 at 8:56
  • 1
    Try "+0.#;-0.#" or "+#.00;-#.00" Commented Aug 29, 2012 at 9:02
  • please improve your question by given some more details Commented Aug 29, 2012 at 9:03
  • possible duplicate of Custom numeric format string to always display the sign Commented Aug 29, 2012 at 9:03

1 Answer 1

5

Use the semicolon seperator to define different formats for positive and negative values, for example

string.Format("{0:+0.0;-0.0}", floatValue)

If you don't want to have a sign before a zero, then use a third option:

edsettings.DisplayFormatString = "+0.#;-0.#;0";

Ref: http://msdn.microsoft.com/en-us/library/0c899ak8.aspx#SectionSeparator

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.