DataGrid 属性有CSSCLASS,好像引入带有Backgroud的CSS文件是可以的,不过我也具体记不太清了

解决方案 »

  1.   

    BackgroundImage
    是有用的,不过如果你设置了行的颜色,就遮住了。
      

  2.   

    BackgroundImage
    是有用的,不过如果你设置了行的颜色,就遮住了。
      

  3.   

    行中背景色是在BackgroundImage的前面的,BackgroundImage也起作用了。只不过在背景色后面呢。
      

  4.   

    工具箱中的DataGrid控件是没有BackgroundImage属性的;
    我自己做了一个继承自DataGrid的grid类,重载BackgroundImage属性后,发现设置这个属性没有用,不知道是否象楼上说的...后来又试了一下重载OnPaint、OnPaintBackground等方法,用Reflector.exe看了一下DataGrid的OnPaint()方法,不知从何入手,哪位大侠能帮解释一下下面的代码,里面好多东西都是受保护级别的,要如何来用 protected override void OnPaint(PaintEventArgs pe)
    {
          try
          {
                this.CheckHierarchyState();
                if (this.layout.dirty)
                {
                      this.ComputeLayout();
                }
                Graphics graphics1 = pe.Graphics;
                Region region1 = graphics1.Clip;
                if (this.layout.CaptionVisible)
                {
                      this.caption.Paint(graphics1, this.layout.Caption, this.isRightToLeft());
                }
                if (this.layout.ParentRowsVisible)
                {
                      graphics1.FillRectangle(SystemBrushes.AppWorkspace, this.layout.ParentRows);
                      this.parentRows.Paint(graphics1, this.layout.ParentRows, this.isRightToLeft());
                }
                Rectangle rectangle1 = this.layout.Data;
                if (this.layout.RowHeadersVisible)
                {
                      rectangle1 = Rectangle.Union(rectangle1, this.layout.RowHeaders);
                }
                if (this.layout.ColumnHeadersVisible)
                {
                      rectangle1 = Rectangle.Union(rectangle1, this.layout.ColumnHeaders);
                }
                graphics1.SetClip(rectangle1);
                this.PaintGrid(graphics1, rectangle1);
                graphics1.Clip = region1;
                region1.Dispose();
                this.PaintBorder(graphics1, this.layout.ClientRectangle);
                graphics1.FillRectangle(DataGrid.DefaultHeaderBackBrush, this.layout.ResizeBoxRect);
                base.OnPaint(pe);
          }
          catch (Exception)
          {
                if ((this.Site == null) || !this.Site.DesignMode)
                {
                      throw;
                }
                this.gridState[0x800000] = true;
                try
                {
                      bool flag1;
                      MessageBox.Show(SR.GetString("DataGridExceptionInPaint"));
                      base.BeginUpdateInternal();
                      this.parentRows.Clear();
                      this.caption.BackButtonVisible = flag1 = false;
                      this.caption.DownButtonActive = flag1 = flag1;
                      this.caption.BackButtonActive = flag1;
                      this.caption.SetDownButtonDirection(!this.layout.ParentRowsVisible);
                      this.originalState = null;
                      this.Set_ListManager(null, string.Empty, true);
                      return;
                }
                finally
                {
                      this.gridState[0x800000] = false;
                      base.EndUpdateInternal();
                }
          }
    }
     
    顺便问一下,不知道大家做项目时用的什么grid控件?