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为按钮

点中按钮获取焦点行

1 if (this.gvMain_Blood.FocusedRowHandle < 0)
2                 return;

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

1  DevExpress.XtraGrid.Views.Grid.GridView gv = (DevExpress.XtraGrid.Views.Grid.GridView)gcMain.FocusedView;
2             int a = gv.FocusedRowHandle;
3             if (a < 0)
4                 return;

 

3、Appearance

FocusedRow 被选中行样式设置

EvenRow  偶数行样式设置

OddRow   奇数行样式设置

GroupRow 分组行样式设置

4、其它属性设置

ExpandMasterRow 展开所有子表

1          if (gv.RowCount > 0)
2             {
3                 for (int i = 0; i < gv.RowCount; i++)
4                 {
5                     this.gv.ExpandMasterRow(i);
6                 }
7             }

 

 二、事件

CustomDrawRowIndicator 自动添加行号

 

1  if (e.Info.IsRowIndicator &&e.RowHandle>=0)
2        {
3         e.Info.DisplayText = (e.RowHandle + 1).ToString();
4        }

 

CustomUnboundColumnData  非绑定列数据绑定

1 if (e.RowHandle < 0)
2                 return;
3 if (e.Column.FieldName == "非绑定列列名") 
4      {
5       e.vaule="";
6      }

RowClick 行选中事件

CustomColumnDisplayText 自定义列

1 //绑定列值为空时显示固定字符串
2 if (e.Column.FieldName == "列名")
3             {
4                 if (e.Value == null)
5                 {
6                     e.DisplayText = "字符串";
7                 }
8             }

 

Blood_MasterRowGetChildList 绑定从表数据

 

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

 

  

 

MasterRowGetRelationCount 设置从表个数

 

e.RelationCount = 1;

 

  

 

MasterRowGetRelationName 主从表关系设置

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

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

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

 

 

 

posted @ 2013-08-16 14:59  ku:k  阅读(651)  评论(0编辑  收藏  举报