DevExpress GridControl 常用事件

 事件

根据状态显示要设置行的颜色

  private void gridView1_RowStyle(object sender, DevExpress.XtraGrid.Views.Grid.RowStyleEventArgs e)

        {

            GridView View = senderas GridView;

            if (e.RowHandle >= 0)

            {

                string category = View.GetRowCellDisplayText(e.RowHandle, View.Columns["AUTHSTATUSDESC"]);

                if (category =="认证未通过")

                {

                    e.Appearance.BackColor =Color.Crimson;

                    e.Appearance.BackColor2 =Color.SeaShell;

                }

                else if (category == "认证通过")

                {

                    e.Appearance.BackColor =Color.DeepSkyBlue;

                    e.Appearance.BackColor2 =Color.SeaShell;

                }

            }

        }


双击行时,显示对应的TabPage页

  private void gridView1_RowClick(object sender, DevExpress.XtraGrid.Views.Grid.RowClickEventArgs e)

        {

                      if (e.Button == System.Windows.Forms.MouseButtons.Left && e.Clicks == 2

            {

                XtraTabControl1.SelectedTabPage = pageDetail;

            }

        }

此功能同DoubleClick事件

private void gridView1_DoubleClick(object sender,EventArgs e)

        {

           XtraTabControl1.SelectedTabPage = pageDetail;

 

        }

 

如何在查询得到0条记录时显示自定义的字符提示/显示

 private void gridView1_CustomDrawEmptyForeground(object sender, DevExpress.XtraGrid.Views.Base.CustomDrawEventArgs e)

        {

            if (this.gridView1.RowCount == 0)

            {

                string str = "没有符合条件的数据!";

                System.Drawing.Font f = new System.Drawing.Font("宋体", 10, FontStyle.Bold);

                Rectangle r = new Rectangle(e.Bounds.Left + 5, e.Bounds.Top + 5, e.Bounds.Width - 5, e.Bounds.Height - 5);

                e.Graphics.DrawString(str, f, Brushes.Black, r);

            }

        }


显示水平滚动条

设置this.gridView1.OptionsView.ColumnAutoWidth = false;

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

定位到第一条数据/记录?

设置 this.gridView.MoveFirst()

定位到下一条数据/记录?

设置 this.gridView.MoveNext()

定位到最后一条数据/记录?

设置 this.gridView.MoveLast()




  • 1
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值