GridView.CustomDrawCell事件可以对GridView展示的列进行处理.
gridView1.CustomDrawCell += gridView1_CustomDrawCell;
void gridView1_CustomDrawCell(object sender, DevExpress.XtraGrid.Views.Base.RowCellCustomDrawEventArgs e)
{
if (e.Column.FieldName == "Status")
{
if (e.CellValue != null)
{
string s = e.CellValue.ToString();
switch (e.CellValue.ToString())
{
case "True": e.DisplayText = "是"; break;
case "False": e.DisplayText = "否"; break;
default: break;
}
}
}
}
//获得选中行的某列值
gridView1.GetDataRow(gridView1.FocusedRowHandle)["ID"].ToString();
本文介绍如何使用GridView的CustomDrawCell事件来自定义显示单元格的内容。通过示例代码展示了如何将布尔值转换为中文“是”或“否”,并介绍了获取选中行指定列值的方法。
476

被折叠的 条评论
为什么被折叠?



