一種方法是使用塗料()事件來檢查行,如果沒有,那麼你的留言: 收起
private void dataGridView1_Paint (object sender, PaintEventArgs e)
{
DataGridView sndr = (DataGridView)sender;
if (sndr.Rows.Count == 0) // <-- if there are no rows in the DataGridView when it paints, then it will create your message
{
using (Graphics grfx = e.Graphics)
{
// create a white rectangle so text will be easily readable
grfx.FillRectangle (Brushes.White, new Rectangle (new Point(), new Size (sndr.Width, 25)));
// write text on top of the white rectangle just created
grfx.DrawString ("No data returned", new Font ("Arial", 12), Brushes.Black, new PointF (3, 3));
}
}
}
感謝JOAT-MON爲接受解決方案
感謝, Imdadhusen