- 列单选事件
1. CheckEdit.Properties.CheckStyle = DevExpress.XtraEditors.Controls.CheckStyles.Radio; int checkedRowIndex = -1; private void gridView1_CellValueChanging(object sender, DevExpress.XtraGrid.Views.Base.CellValueChangedEventArgs e) { GridView view = sender as GridView; if (e.Column.FieldName == "IsSelected" && (bool)e.Value) { int rowHandle = view.GetRowHandle(checkedRowIndex); view.SetRowCellValue(rowHandle, "IsSelected", false); checkedRowIndex = view.GetDataSourceRowIndex(e.RowHandle); } }
- 行单选事件
此外,确保在您所设定的所有单选按钮设置RadioGroupIndex相同的索引编号。 - 数值类型保留2位小数,即使小数位最后面是0
{0:f2} - 自定义列展示内容
private void gridView1_CustomColumnDisplayText(object sender, DevExpress.XtraGrid.Views.Base.CustomColumnDisplayTextEventArgs e)
{
if (e.Column.FieldName == "Associated")
{
if (e.Value != null)
{
GridView view = sender as GridView;
switch (e.Value.ToString().Trim().ToLower())
{
case "true":
e.DisplayText = "已关联";
break;
default:
{
if (view.GetListSourceRowCellValue(e.ListSourceRowIndex, "IsSplit").ToString().ToLower() == "true" &&
view.GetListSourceRowCellValue(e.ListSourceRowIndex, "ParentID").ToString() == "00000000-0000-0000-0000-000000000000")
{
e.DisplayText = "";
}
else
{
e.DisplayText = "未关联";
}
}
break;
}
// 如果已拆单 并且 parent = IsSplit00000000-0000-0000-0000-000000000000 那么
/**/
}
}
else if (e.Column.FieldName == "IsSplit")
{
if (e.Value != null)
{
switch (e.Value.ToString().Trim().ToLower())
{
case "true":
e.DisplayText = "已拆分";
break;
case "false":
e.DisplayText = "未拆分";
break;
default:
e.DisplayText = "未拆分";
break;
}
}
}
}
标签:Devpress,GridView,0000,技巧,Value,break,DisplayText,view
From: https://www.cnblogs.com/maanshancss/p/16907376.html