当前位置: 移动技术网 > IT编程>开发语言>c# > DevExpress实现GridView当无数据行时提示消息

DevExpress实现GridView当无数据行时提示消息

2019年07月18日  | 移动技术网IT编程  | 我要评论

本文实例展示了devexpress实现gridview当无数据行时提示消息的方法,具体步骤如下:

主要功能代码部分如下:

/// <summary>
/// 设置当没有数据行的提示信息『customdrawemptyforeground』
/// </summary>
/// <param name="gridview">gridview</param>
/// <param name="e">customdraweventargs</param>
/// <param name="norecordmsg">提示信息</param>
public static void drawnorowcountmessage(this gridview gridview, customdraweventargs e, string norecordmsg)
{
  if (gridview == null)
 throw new argumentnullexception("gridview");
  if (gridview.rowcount == 0)
  {
 if (!string.isnullorempty(norecordmsg))
 {
   font _font = new 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(norecordmsg, _font, brushes.black, _r);
 }
  }
}

代码使用方法如下:

private void gvlamptotal_customdrawemptyforeground(object sender, devexpress.xtragrid.views.base.customdraweventargs e)
{
  gvlamptotal.drawnorowcountmessage(e, "暂无符合的数据!");
}

代码运行效果如下:

如对本文有疑问, 点击进行留言回复!!

相关文章:

验证码:
移动技术网