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?
Asked
Active
Viewed 2,867 times
0
-
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 Answers
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
-
He has a "winforms" tag in the question. I guess you are talking about ASP.NET. But I also guess that there is winforms equivalent for this. – Mohammad Dehghan Jun 15 '14 at 09:21
-
Good :) But your code example is VB.NET. He is asking about C# :) – Mohammad Dehghan Jun 15 '14 at 09:35
-
@DianaNassar I have Column Already Added i don't wanna to add it again it has many other functions to add new one i wanna set it only accept Decimal – SOFKiNG Jun 15 '14 at 10:20
-