DevExpress完成GridView當有數據行時提醒新聞。本站提示廣大學習愛好者:(DevExpress完成GridView當有數據行時提醒新聞)文章只能為提供參考,不一定能成為您想要的結果。以下是DevExpress完成GridView當有數據行時提醒新聞正文
本文實例展現了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, "暫無相符的數據!"); }
代碼運轉後果以下: