DEV Gridcontrol 查询得到0条记录时显示自定义的字符提示/显示

private void gridView_CustomDrawEmptyForeground(object sender, DevExpress.XtraGrid.Views.Base.CustomDrawEventArgs e)
        {
            if (this.judge_ds(dsDt))
            {
                string str = "没有查询到你所想要的数据!";
                Font f = new Font("宋体", 10, FontStyle.Bold);
                Rectangle r = new Rectangle(e.Bounds.Top + 25, e.Bounds.Left + 25, e.Bounds.Right - 25, e.Bounds.Height - 25);
                e.Graphics.DrawString(str, f, Brushes.Black, r);
            }
        }
#region 判断ds是否为空
        private bool judge_ds(DataSet ds)
        {
            bool flag = false;
            if (ds == null||ds.Tables.Count == 0||(ds.Tables.Count == 1 && ds.Tables[0].Rows.Count == 0))
            {
                flag = true;
            }
            return flag;
        }  
        #endregion

小注:

如果显示提示信息的位置不对可以通过调整,Rectangle函数后面的数字来实现。

作者:jiankunking 出处:http://blog.csdn.net/jiankunking
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值