RadGrid列只接受小数
本文关键字:小数 RadGrid | 更新日期: 2023-09-27 18:08:36
我有RadGrid
,需要设置列只接受Decimals
(货币格式)并禁用其他字符。如何设置列只接受Decimals
格式?
可以使用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