DEV GridControl 小结(持续添加)

时间:2023-03-09 12:48:47
DEV GridControl 小结(持续添加)

一、属性:

1、Views

OptionsBehavior=>Editable:False  列表不可编辑

OptionsSelection=>EnableAppearanceFocusedCell :False   选中整行

在设置了奇偶行样式后需要起用设置,不然无效

OptinsView=>EnableAppearanceEvenRow :True   起用偶数行样式

OptinsView=>EnableAppearanceOddRow :True    起用奇数行样式

OptinsView=>ShowGroupPanel:False   隐藏分组面板

2、Columns

SortOrder 设置按该列排序方法 (Descending:降序 ;Ascending:升序)

UnboundType  设置为非绑定列,并设置数据类型

ColumnsEdit 可以在该列中添加控件,在 In-place Editor中添加控件,ButoonEdit为按钮

点中按钮获取焦点行

 if (this.gvMain_Blood.FocusedRowHandle < )
return;

如果设置了主从表结构,那么在从表中为

  DevExpress.XtraGrid.Views.Grid.GridView gv = (DevExpress.XtraGrid.Views.Grid.GridView)gcMain.FocusedView;
int a = gv.FocusedRowHandle;
if (a < )
return;

3、Appearance

FocusedRow 被选中行样式设置

EvenRow  偶数行样式设置

OddRow   奇数行样式设置

GroupRow 分组行样式设置

4、其它属性设置

ExpandMasterRow 展开所有子表

          if (gv.RowCount > )
{
for (int i = ; i < gv.RowCount; i++)
{
this.gv.ExpandMasterRow(i);
}
}

二、事件

CustomDrawRowIndicator 自动添加行号

  if (e.Info.IsRowIndicator &&e.RowHandle>=)
{
e.Info.DisplayText = (e.RowHandle + ).ToString();
}

CustomUnboundColumnData  非绑定列数据绑定

 if (e.RowHandle < )
return;
if (e.Column.FieldName == "非绑定列列名")
{
e.vaule="值";
}

RowClick 行选中事件

CustomColumnDisplayText 自定义列

 //绑定列值为空时显示固定字符串
if (e.Column.FieldName == "列名")
{
if (e.Value == null)
{
e.DisplayText = "字符串";
}
}

Blood_MasterRowGetChildList 绑定从表数据

if (e.RowHandle < 0)
return;
List<T> dateList=new List<T>
e.ChildList = dateList

  

MasterRowGetRelationCount 设置从表个数

e.RelationCount = 1;

  

MasterRowGetRelationName 主从表关系设置

  e.RelationName = "Detail"; //从表LevelName 一定要设置为Detail才能关联主从表

CustomDrawEmptyForeground  查询得到0条数据时显示自定义字符

 if (this.gv.RowCount==)
{
string str = "没有查询到信息!";
Font f = new Font("宋体", , FontStyle.Bold);
Rectangle r = new Rectangle(e.Bounds.Left + , e.Bounds.Top + , e.Bounds.Width - , e.Bounds.Height - );
e.Graphics.DrawString(str, f, Brushes.Black, r);
}