DEV GridControl表格数据源为空在表格中间显示提醒字符

private static void gv_CustomDrawEmptyForeground(object sender, DevExpress.XtraGrid.Views.Base.CustomDrawEventArgs e)
   {
      DevExpress.XtraGrid.Views.Grid.GridView gv = sender as DevExpress.XtraGrid.Views.Grid.GridView;
      DataView bindingSource = gv.DataSource as DataView;
      
      if (bindingSource != null & bindingSource.Count == 0)
      {
         Font f = new Font("宋体", 16, FontStyle.Bold);
         Rectangle r = new Rectangle(gv.GridControl.Width / 2 - 100, gv.GridControl.Height / 2, e.Bounds.Right - 5, e.Bounds.Height - 5);
         e.Graphics.DrawString("没有查询到数据!", f, Brushes.Red, r);
      }
   }
原文地址:https://www.cnblogs.com/DoNetCShap/p/5341988.html