怎么在dataGridView上提示没检索到数据 大家好: 我想在 从数据库中读取数据时 如果没有检索到相关数据 怎样在dataGridView上 提示 没有检索到数据 呢? 谢谢大家了! 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 http://blog.csdn.net/califord/archive/2006/03/03/614439.aspx 判断一下有没数据,然后让GRIDVIEW不显示,一个DIV就显示暂无数据 datagridview应该也有一个属性: empty显示的吧 using System;using System.Collections.Generic;using System.ComponentModel;using System.Data;using System.Drawing;using System.Text;using System.Windows.Forms;namespace WindowsApplication259{ public partial class Form1 : Form { DataGridViewEx DGV = new DataGridViewEx(); public Form1() { InitializeComponent(); DGV.Columns.Add("c1", "c1"); DGV.Parent = this; DGV.Dock = DockStyle.Fill; DGV.AllowUserToAddRows = false; Button B = new Button(); B.Parent = DGV; B.Text = "加载"; B.Click += new EventHandler(B_Click); } void B_Click(object sender, EventArgs e) { DGV.Rows.Add(); } class DataGridViewEx : DataGridView { protected override void OnPaint(PaintEventArgs e) { base.OnPaint(e); if (this.RowCount == 0) { String S = "没有检索到数据"; SizeF SF = e.Graphics.MeasureString(S, this.Font); e.Graphics.DrawString(S, this.Font, Brushes.Silver, (this.ClientRectangle.Width - SF.Width) / 2, (this.ClientRectangle.Height - SF.Height) / 2); } } protected override void OnResize(EventArgs e) { base.OnResize(e); this.Invalidate(); } } }} C# 注册服务---启动服务问题 退出确认保存 相似度比较....... SQL的存储过程的使用 100分求两个控件 公司要自主开发一个PDM,用java好还是.net好?各位给个建议吧。 C#怎么设置指定进程的HOOK 关于调试的问题?? 关于线程同步AutoResetEvent类的一些问题疑惑 高分求教,如何在C#中调用ActiveX控件?急,急 .net 新手问题 c#在窗体上新建文件夹
应该也有一个属性: empty显示的吧
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;namespace WindowsApplication259
{
public partial class Form1 : Form
{
DataGridViewEx DGV = new DataGridViewEx(); public Form1()
{
InitializeComponent(); DGV.Columns.Add("c1", "c1");
DGV.Parent = this;
DGV.Dock = DockStyle.Fill;
DGV.AllowUserToAddRows = false; Button B = new Button();
B.Parent = DGV;
B.Text = "加载";
B.Click += new EventHandler(B_Click);
} void B_Click(object sender, EventArgs e)
{
DGV.Rows.Add();
} class DataGridViewEx : DataGridView
{
protected override void OnPaint(PaintEventArgs e)
{
base.OnPaint(e); if (this.RowCount == 0)
{
String S = "没有检索到数据";
SizeF SF = e.Graphics.MeasureString(S, this.Font); e.Graphics.DrawString(S, this.Font, Brushes.Silver,
(this.ClientRectangle.Width - SF.Width) / 2, (this.ClientRectangle.Height - SF.Height) / 2);
}
} protected override void OnResize(EventArgs e)
{
base.OnResize(e);
this.Invalidate();
}
}
}
}