DEV 设置筛选行
作者:互联网
1、效果如下
2、设置
gridView1.OptionsCustomization.AllowFilter = true; //是否允许过滤
gridView1.IndicatorWidth = 40; //行标题高度
gridView1.OptionsView.ShowIndicator = true; // 显示行标题
注册写行号事件
gridView1.CustomDrawRowIndicator += new DevExpress.XtraGrid.Views.Grid.RowIndicatorCustomDrawEventHandler(gridView1_CustomDrawRowIndicator);
private void gridView1_CustomDrawRowIndicator(object sender, DevExpress.XtraGrid.Views.Grid.RowIndicatorCustomDrawEventArgs e)
{
e.Appearance.TextOptions.HAlignment = DevExpress.Utils.HorzAlignment.Center; //行号对齐方式
if (e.RowHandle == GridControl.AutoFilterRowHandle)
{
e.Info.DisplayText = "筛选行"; //筛选行加行标题
}
if (e.Info.IsRowIndicator && e.RowHandle >= 0)
{
e.Info.DisplayText = (e.RowHandle +1).ToString() ; //行号
}
}
3、修改默认筛选条件
if (list.Count > 20) //大于20行时,显示筛选行
{
gridView1.OptionsView.ShowAutoFilterRow = true;
foreach (DevExpress.XtraGrid.Columns.GridColumn item in gridView1.Columns)
{
item.OptionsFilter.AutoFilterCondition = DevExpress.XtraGrid.Columns.AutoFilterCondition.Contains; //筛选条件设置为包含
}
}
标签:DevExpress,DEV,设置,RowHandle,gridView1,筛选,Columns,XtraGrid 来源: https://www.cnblogs.com/huangkeqiang/p/14512276.html