我有RadGrid
并且需要设置列只接受Decimals
(货币格式)并禁用其他字符。如何将列设置为仅接受Decimals
格式?
答案 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