RadGrid列只接受小数?

时间:2014-06-15 08:52:44

标签: c# winforms telerik radgrid

我有RadGrid并且需要设置列只接受Decimals(货币格式)并禁用其他字符。如何将列设置为仅接受Decimals格式?

1 个答案:

答案 0 :(得分:1)

您可以使用GridNumericColumn

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

修改

如果您确实询问winforms,那么上面的等价物是GridViewDecimalColumn

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

<强> EDIT2

尝试:

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

详细了解:http://www.telerik.com/help/winforms/gridview-columns-data-formatting.html