Sta*_*ros 8 devexpress xtragrid
我有一个xtragrid与存储过程中的值.
我得到float(0.23)中的值,我想以百分比(23%)显示.
在C#中最好的方法是什么?
之前
后

Nir*_*ngh 10
如果您只想以只读方式显示单元格,请使用CustomDrawCell事件.或者您也可以使用CustomColumnDisplayText事件.
试试这个:
private void gridView1_CustomDrawCell(object sender, DevExpress.XtraGrid.Views.Base.RowCellCustomDrawEventArgs e)
{
if (e.Column.FieldName == "Marks")
{
e.DisplayText = (((int)(Convert.ToDecimal(e.CellValue) * 100))).ToString() + "%";
}
}
Run Code Online (Sandbox Code Playgroud)
另一种方法是使用Editor EditFormat和DisplayFormat属性.设置这些属性后,将其添加到gridview列:Ref:如何格式化XtraGrid中显示的值
RepositoryItem textEdit;
private void AddGridRepositoryItem()
{
textEdit = new RepositoryItemTextEdit();
textEdit.AllowHtmlDraw = DevExpress.Utils.DefaultBoolean.True;
textEdit.ReadOnly = true;
gridControl1.RepositoryItems.Add(textEdit);
textEdit.DisplayFormat.FormatType = DevExpress.Utils.FormatType.Numeric;
textEdit.DisplayFormat.FormatString = "p";
gridView1.Columns[0].ColumnEdit = textEdit;
}
Run Code Online (Sandbox Code Playgroud)
最简单的方法是使用GridColumn.DisplayFormat属性.
colPayment.DisplayFormat.FormatType = FormatType.Numeric;
colPayment.DisplayFormat.FormatString = "p0";
Run Code Online (Sandbox Code Playgroud)
希望这有帮助..
请使用以下方法:
colReabilitation.DisplayFormat.FormatType = DevExpress.Utils.FormatType.Numeric;
colReabilitation.DisplayFormat.FormatString = "p0";
Run Code Online (Sandbox Code Playgroud)
相关链接:
| 归档时间: |
|
| 查看次数: |
28177 次 |
| 最近记录: |