Rovan

      一个犁牛半块田,收也凭天,荒也凭天, 清茶淡饭饱三餐,早也香甜,晚也香甜, 布衣得暖胜丝绵,长也可穿,短也可穿, 草舍茅屋有几间,行也安然,待也安然, 雨过天青驾小船,鱼在一边,酒在一边, 夜归儿女话灯前,今也有言,古也有言, 日上三竿我独眠,请是神仙,我是神仙.

首页 新随笔 联系 订阅 管理

using System;
using System.Windows.Forms;
using System.Drawing;

namespace Rovan.Controls
{
 /// <summary>
 /// Rovan 的摘要说明。
 /// </summary>
 public class RovanDataGrid :DataGrid
 {
  public RovanDataGrid()
  {
   //
   // TODO: 在此处添加构造函数逻辑
   //
   
   this.CurrentCellChanged +=new EventHandler(RovanDataGrid_CurrentCellChanged);
   this.TableStyles.CollectionChanged +=new System.ComponentModel.CollectionChangeEventHandler(TableStyles_CollectionChanged);
   this.BackgroundColor = Color.FromArgb(231, 240, 247);
   this.RowHeaderWidth = 15;
   this.HeaderBackColor =   Color.FromArgb(191, 213, 236);
   this.AlternatingBackColor =  Color.FromArgb(231, 240, 247);
   this.SelectionBackColor = System.Drawing.SystemColors.InactiveCaption;
   
  }

  private void RovanDataGrid_CurrentCellChanged(object sender, EventArgs e)
  {
   this.Select(this.CurrentCell.RowNumber);
  }

  private void TableStyles_CollectionChanged(object sender, System.ComponentModel.CollectionChangeEventArgs e)
  {
   foreach(DataGridTableStyle ts in this.TableStyles)
   {
    ts.RowHeaderWidth = this.RowHeaderWidth;
    ts.HeaderBackColor = this.HeaderBackColor;
    ts.AlternatingBackColor = this.AlternatingBackColor;
    ts.SelectionBackColor = this.SelectionBackColor;
   }
  }
 
  
 }
}

posted on 2007-11-20 16:17  Ruxuan  阅读(146)  评论(0)    收藏  举报