#region
///
/// 文件名称: Production_Plan.Lib.MultiHead.cs
/// 创建人: jackhu
/// 创建日期: 2010-9-7 17:13:45
/// 描述信息: 多表头的类
///
/// 修改历史
/// 修改人:
/// 修改时间:
/// 修改说明:
///
#endregion
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Drawing;
using System.Windows.Forms;
namespace Production_Plan.Lib
{
class MultiHead
{
private DataGridView dataGridView;
public MultiHead(DataGridView grid)
{
this.dataGridView = grid;
string title = "";
for (int i = 0; i != this.dataGridView.Columns.Count-1 ; ++i)
{
title += this.dataGridView.Columns[i].HeaderText + ",";
}
title = title.Substring(1, title.Length - 2);
this.titleHead = new string[] { title };
}
//通过构造函出来限制title和格式与grid一致
public MultiHead(DataGridView grid, string[] title)
{
//grid不等于null
for (int i = 0; i != title.Length-1 ; ++i)
{
string[] s = title[i].Split(',');
if (grid.Columns.Count == s.Length)
{
continue;
}
else
{
throw new Exception("title的元素个数与grid的栏位总数不一致.");
}
}
this.dataGridView = grid;
this.titleHead = title;
}
private string[] titleHead;
public string[] TitleHead
{
get
{
return titleHead;
}
}
public void Draw(DataGridViewCellPaintingEventArgs e)
{
if (e.RowIndex == -1)
{
using (
Brush gridBrush = new SolidBrush(this.dataGridView.GridColor),
backColorBrush = new SolidBrush(e.CellStyle.BackColor))
{
using (Pen gridLinePen = new Pen(gridBrush))
{
if (e.ColumnIndex == -1)
{
e