DevExpress-XtraGrid(1)

序言

花更多的时间去探索未知的东西

 

Options
设计
数据
外观
行为
 
CustomDraw
Customization
DataAsyn
Editor
MasterDetail
Merge
Printing
Property Changed
Sort
Sorting
操作
焦点
鼠标
数据
拖放
外观
行为
 
GridControl
CardGridView
GridView
BandedGridView
AdvBandedGridView
LayoutView
 
在DevExpress中GridControl与GridView有什么区别?
 

动态生成Grid表格

hjpm中涉及到的事件

 

DevExpress控件使用

 

事件

 

GirdControl只是一个容器控件,必须要求GridView视图作为它的子控件,也就是说GirdControl里面必有至少有一个GridView,GridControl可以包含多个视图,可以实现视图的切换

GridView常见的一些属性设置

 

gridView1_CustomDrawCell与gridView1_RowCellStyle都可以且用法一样。但是CustomDrawCell更稳定

private void gridView1_CustomDrawCell(object sender, RowCellStyleEventArgs e)
        {
            DevExpress.XtraGrid.Views.Grid.GridView view = sender as DevExpress.XtraGrid.Views.Grid.GridView;
            //列名=a,值=1的标记为绿色
            if (e.CellValue.ToString() == "1" && e.Column.FieldName.ToString().Equals("a"))
            {
                e.Appearance.BackColor = Color.FromArgb(128, 255, 128);
                e.Column.DisplayFormat.FormatString = "yyyy-MM-dd HH:mm:ss";
               
            }
        }
View Code

 

DataTable dt = ((DataView)gridView1.DataSource).ToTable();

DataRow dtContractRow = this.grdContract.GetFocusedDataRow();

 

GridColumn c = new GridColumn();
                c.Name = "code";
                c.Caption = "code";
                c.FieldName = "code";
                //c.OptionsColumn.AllowSize = true;
                //c.OptionsColumn.ReadOnly = true;
                //c.OptionsColumn.AllowEdit = false;
                //c.OptionsColumn.AllowMove = false;
                //c.OptionsColumn.AllowSort = DevExpress.Utils.DefaultBoolean.False;
                //c.OptionsColumn.AllowGroup = DevExpress.Utils.DefaultBoolean.False;
                //c.OptionsFilter.AllowFilter = false;
                //c.OptionsFilter.AllowAutoFilter = false;
                //c.Visible = true;
                gv.Columns.Add(c);
View Code

 

//设置列内容完全显示所需的最佳列宽
gridColumn1.BestFit();

//自动调整所有列的宽度
this.gridView1.BestFitColumns();

 

DevExpress GridControl使用整理

for (int i = 0; i < gridView1.RowCount; i++)
  {
     if (string.IsNullOrEmpty(gridView1.GetRowCellValue(i, "FieldName") as string))
      {
         gridView1.FocusedRowHandle = i;
         var col = gridView1.Columns.Where(c => c.FieldName == "FieldName").FirstOrDefault();
         gridView1.SetColumnError(col, "该字段不能为空,请重新填写!");
      }
  }
View Code

 

 

 

分组 

表头换行

滚动分页

设置字体颜色

空值校验  ValidateRow

拖动

合并表头

格子变色

事件

mainView_CellValueChanged

mainView_CustomColumnDisplayText

mainView_CustomDrawCell

GridControl 使用技巧2——验证单元格输入值

https://www.cnblogs.com/wuhuacong/tag/WinForm%E7%95%8C%E9%9D%A2%E5%BC%80%E5%8F%91/

https://www.cnblogs.com/wuhuacong/archive/2012/07/17/2595182.html

https://www.cnblogs.com/wuhuacong/archive/2012/06/18/2553303.html

gridcontrol中有5种view 型式

普通的是gridview

cardview

BandedView

Advanced BandedView

LayoutView

如何隐藏 GridControl 的 GroupPanel 表头

设置 Run Design->OptionsView->ShowGroupPanel 设置为:false

Devexpress:在GridControl中使用RepositoryItemGridLookUpEdit 进行级联选择

使用PopupContainerEdit和PopupContainer

 private void SetView()
        {
            GridView gridView = (GridView)this.DefaultView;
            if (gridView != null)
            {
                gridView.StartSorting += new EventHandler(gridView_StartSorting);
                gridView.TopRowChanged += new EventHandler(gridView_TopRowChanged);
                gridView.RowCountChanged += new EventHandler(gridView_RowCountChanged);


                isViewSetted = true;
            }
        }

 取得当前选中的行数据

private DataRow GetCurHisRow()

已完成

Grid动态生成鼠标右键  

Dev PopupMenu实现自定义右键菜单,添加二级菜单,添加菜单项分割

资料

DevExpress控件专栏

C# GridControl 的使用小结

DEV—【GridControl主从表】

C# DevExpress控件Gridview和GridControl学习总结

devExpress控件之GridControl、GridView

DevExpress控件的GridControl控件小结

DevExpress控件GridControl使用总结一

dev gridcontrol 导出到excel

posted @ 2019-11-03 16:30  ~沐风  阅读(928)  评论(0编辑  收藏  举报