0

I have RadGrid and need to set column only accept Decimals (money format) and disable other characters. How do I set a column to accept only Decimals format?

Tony L.
  • 17,638
  • 8
  • 69
  • 66
SOFKiNG
  • 385
  • 1
  • 3
  • 20
  • possible duplicate of [Make a specific column only accept numeric value in datagridview in Keypress event](http://stackoverflow.com/questions/12645458/make-a-specific-column-only-accept-numeric-value-in-datagridview-in-keypress-eve) – Sajeetharan Jun 15 '14 at 09:12
  • other Links Not for Telerik WinForms – SOFKiNG Jun 15 '14 at 10:25

1 Answers1

1

You can use a GridNumericColumn:

<telerik:GridNumericColumn DataField="MoneyAmount" DataType="System.Decimal" NumericType="Currency" HeaderText="Money Amount" SortExpression="MoneyAmount" UniqueName="MoneyAmount" DataFormatString="{0:C}"> 
</telerik:GridNumericColumn> 

EDIT

If you are indeed asking about winforms, then the equivalent for the above is GridViewDecimalColumn:

GridViewDecimalColumn currencyColumn = new GridViewDecimalColumn("Currency");
currencyColumn.FormatString = "{0:c}";
myGrid.Columns.Add(currencyColumn);

EDIT2

Try:

GridViewDecimalColumn unitPriceColumn = this.radGridView1.Columns["UnitPrice"] as GridViewDecimalColumn;
unitPriceColumn.FormatString = "Price: {0:C}";
unitPriceColumn.FormatInfo = CultureInfo.CreateSpecificCulture("en-GB");
unitPriceColumn.NullValue = 0;

Check more on: http://www.telerik.com/help/winforms/gridview-columns-data-formatting.html

Diana Nassar
  • 2,303
  • 14
  • 17