项目场景:
DevExpress.XtraGrid.GridControl 选中行高光
问题描述
在GridView中OptionsView中的AllowCellMerge属性开启后,默认选中行高光的效果就没有了,也就是说合并单元格后,高光效果无法显示只能在代码中处理
解决代码
在GridView中注册CustomDrawCell方法,在CustomDrawCell方法中实现目标
private void gdvOrderListView_CustomDrawCell(object sender, DevExpress.XtraGrid.Views.Base.RowCellCustomDrawEventArgs e)
{
var gridView = sender as DevExpress.XtraGrid.Views.Grid.GridView;
var currentOrder = gridView.GetRow(e.RowHandle) as EntityNurseSignatureOrder;//选中行Entity
var RowDateResult = m_OrderList_Overall.FindAll(orderList => orderList.主医嘱ID == currentOrder.主医嘱ID);
if (RowDateResult == null)
return;
#region 选中行高亮
//获取选中的行号
var selectids = gridView.GetSelectedRows();
//选中行颜色改变
if (selectids.Contains(e.RowHandle))
{
e.Appearance.BackColor = Color.FromArgb(122, 150, 223);
e.Appearance.ForeColor = Color.White;
}
#endregion
}
后续待处理问题
当选中合并列的其中一行时,将合并列全部选中