DataGridView扩展:带设置背景图片的DataGridView
比默认灰土色要好多了。
Code
1using System;
2using System.Collections.Generic;
3using System.Text;
4using System.Drawing;
5using System.ComponentModel;
6namespace pcd.WinControl
7{
8 public class DataGridViewWithBackGround : System.Windows.Forms.DataGridView
9 {
10 private Image m_Image;
11 [Description("设置或获取DataGridView的背景图片")]
12 public Image BackGroundImage
13 {
14 get { return m_Image; }
15 set { m_Image = value; }
16 }
17 protected override void PaintBackground(Graphics graphics, Rectangle clipBounds, Rectangle gridBounds)
18 {
19 base.PaintBackground(graphics, clipBounds, gridBounds);
20 if (m_Image != (Image)null)
21 graphics.DrawImage(m_Image, gridBounds);
22 }
23 }
24}
25
1using System;
2using System.Collections.Generic;
3using System.Text;
4using System.Drawing;
5using System.ComponentModel;
6namespace pcd.WinControl
7{
8 public class DataGridViewWithBackGround : System.Windows.Forms.DataGridView
9 {
10 private Image m_Image;
11 [Description("设置或获取DataGridView的背景图片")]
12 public Image BackGroundImage
13 {
14 get { return m_Image; }
15 set { m_Image = value; }
16 }
17 protected override void PaintBackground(Graphics graphics, Rectangle clipBounds, Rectangle gridBounds)
18 {
19 base.PaintBackground(graphics, clipBounds, gridBounds);
20 if (m_Image != (Image)null)
21 graphics.DrawImage(m_Image, gridBounds);
22 }
23 }
24}
25