GridControl 无数据时显示信息

时间:2022-12-08 19:07:14

图例:

GridControl 无数据时显示信息

主要代码如下:

说明:给GridView添加事件gv_CustomDrawEmptyForeground

  private void gv_CustomDrawEmptyForeground(object sender, DevExpress.XtraGrid.Views.Base.CustomDrawEventArgs e)
{
int num = 100;
if (DSMain.Tables[0].Rows.Count < 1) {
string str = "没有找到你要查询的数据!";
Font f = new Font("华文中宋", 10, FontStyle.Regular);
Rectangle rec = new Rectangle(e.Bounds.Top + num, e.Bounds.Left + num, e.Bounds.Right - num, e.Bounds.Bottom - num);
e.Graphics.DrawString(str, f, Brushes.Black, rec);
}
}

版权声明:本文为博主原创文章,未经博主允许不得转载。