 
                    
                
         
    
    
    
	
	
		
		
  
  
  
  
  
 
		
			
	
	
 

 设置datagridview的一些row和cell的方法,例如产生row,将值插入到一个row中并返回#region 设置datagridview的一些row和cell的方法,例如产生row,将值插入到一个row中并返回
        设置datagridview的一些row和cell的方法,例如产生row,将值插入到一个row中并返回#region 设置datagridview的一些row和cell的方法,例如产生row,将值插入到一个row中并返回

 /**//// <summary>
        /**//// <summary>
 /// 返回一个实例化之后的DataGridViewRow对象
        /// 返回一个实例化之后的DataGridViewRow对象
 /// </summary>
        /// </summary>
 /// <param name="columnCount">DataGridViewRow对象包含的列的数量</param>
        /// <param name="columnCount">DataGridViewRow对象包含的列的数量</param>
 /// <param name="firstColumnType">第一个列的类型是什么</param>
        /// <param name="firstColumnType">第一个列的类型是什么</param>
 /// <returns>初始化好了的datagridviewrow对象</returns>
        /// <returns>初始化好了的datagridviewrow对象</returns>
 public static DataGridViewRow GenerateDgvCommonRow(int columnCount,
        public static DataGridViewRow GenerateDgvCommonRow(int columnCount,
 AddSpecialColumnType firstColumnType)
                                                           AddSpecialColumnType firstColumnType)

 
         {
{
 DataGridViewRow tmpRow = new DataGridViewRow();
            DataGridViewRow tmpRow = new DataGridViewRow();
 for (int i = 0; i < columnCount; i++)
            for (int i = 0; i < columnCount; i++)

 
             {
{
 if (i > 0)//第二列开始加入的都是文本框
                if (i > 0)//第二列开始加入的都是文本框

 
                 {
{
 tmpRow.Cells.Add(new DataGridViewTextBoxCell());
                    tmpRow.Cells.Add(new DataGridViewTextBoxCell());
 }
                }
 else//第一列根据用户的输入参数来决定,默认是文本框
                else//第一列根据用户的输入参数来决定,默认是文本框

 
                 {
{
 switch (firstColumnType)
                    switch (firstColumnType)

 
                     {
{
 case AddSpecialColumnType.CheckBox:
                        case AddSpecialColumnType.CheckBox:
 //tmpRow.Cells.Add(new DataGridViewCheckBoxColumn());
                            //tmpRow.Cells.Add(new DataGridViewCheckBoxColumn()); 
 DataGridViewCheckBoxCell tmpCell = new DataGridViewCheckBoxCell();
                            DataGridViewCheckBoxCell tmpCell = new DataGridViewCheckBoxCell();
 tmpCell.Value = false;
                            tmpCell.Value = false;
 //tmpRow.Cells.Add(new DataGridViewCheckBoxCell());
                            //tmpRow.Cells.Add(new DataGridViewCheckBoxCell()); 
 tmpRow.Cells.Add(tmpCell);
                            tmpRow.Cells.Add(tmpCell);
 break;
                            break;
 case AddSpecialColumnType.ComboBox:
                        case AddSpecialColumnType.ComboBox:
 tmpRow.Cells.Add(new DataGridViewComboBoxCell());
                            tmpRow.Cells.Add(new DataGridViewComboBoxCell());
 //tmpRow.Cells.Add(new DataGridViewComboBoxColumn());
                            //tmpRow.Cells.Add(new DataGridViewComboBoxColumn()); 
 break;
                            break;
 case AddSpecialColumnType.TextBox:
                        case AddSpecialColumnType.TextBox:
 tmpRow.Cells.Add(new DataGridViewTextBoxCell());
                            tmpRow.Cells.Add(new DataGridViewTextBoxCell());
 //tmpRow.Cells.Add(new DataGridViewTextBoxColumn());
                            //tmpRow.Cells.Add(new DataGridViewTextBoxColumn()); 
 break;
                            break;
 default:
                        default:
 tmpRow.Cells.Add(new DataGridViewTextBoxCell());
                            tmpRow.Cells.Add(new DataGridViewTextBoxCell());
 //tmpRow.Cells.Add(new DataGridViewTextBoxColumn());
                            //tmpRow.Cells.Add(new DataGridViewTextBoxColumn()); 
 break;
                            break;
 }
                    }
 }
                }
 }
            }
 return tmpRow;
            return tmpRow;
 }
        }

 /**//// <summary>
        /**//// <summary>
 /// 点击全选的时候调用的方法
        /// 点击全选的时候调用的方法
 /// </summary>
        /// </summary>
 /// <param name="HandledDgView">需要处理的DataGridView</param>
        /// <param name="HandledDgView">需要处理的DataGridView</param>
 /// <param name="checkBosPos">checkbox的位置</param>
        /// <param name="checkBosPos">checkbox的位置</param>
 public static void GetAllCheckBokChecked(ref DataGridView HandledDgView,
        public static void GetAllCheckBokChecked(ref DataGridView HandledDgView,
 int checkBosPos)
            int checkBosPos)

 
         {
{
 foreach (DataGridViewRow row in HandledDgView.Rows)
            foreach (DataGridViewRow row in HandledDgView.Rows)

 
             {
{
 if ((row.Cells[checkBosPos].GetType().Equals(typeof(DataGridViewCheckBoxCell))))
                if ((row.Cells[checkBosPos].GetType().Equals(typeof(DataGridViewCheckBoxCell))))

 
                 {
{
 DataGridViewCheckBoxCell CheckBoxCol =
                    DataGridViewCheckBoxCell CheckBoxCol =
 (DataGridViewCheckBoxCell)row.Cells[checkBosPos];
                                (DataGridViewCheckBoxCell)row.Cells[checkBosPos];
 if (CheckBoxCol.Value == null)
                    if (CheckBoxCol.Value == null)

 
                     {
{
 CheckBoxCol.Value = true;
                        CheckBoxCol.Value = true;
 }
                    }
 if (CheckBoxCol.Value.ToString() == "False")//如果被选择了,加入航班执行日期
                    if (CheckBoxCol.Value.ToString() == "False")//如果被选择了,加入航班执行日期

 
                     {
{
 CheckBoxCol.Value = true;
                        CheckBoxCol.Value = true;
 }
                    }
 //else
                    //else
 //{
                    //{
 //    CheckBoxCol.Value = false;
                    //    CheckBoxCol.Value = false;
 //}
                    //} 
 }
                }
 }
            }
 }
        }
 
       

 /**//// <summary>
        /**//// <summary>
 /// 点击反向全选的时候调用的方法
        /// 点击反向全选的时候调用的方法
 /// </summary>
        /// </summary>
 /// <param name="HandledDgView">需要处理的DataGridView</param>
        /// <param name="HandledDgView">需要处理的DataGridView</param>
 /// <param name="checkBosPos">checkbox的位置</param>
        /// <param name="checkBosPos">checkbox的位置</param>
 public static void GetAllCheckBokReverseChecked(ref DataGridView HandledDgView,
        public static void GetAllCheckBokReverseChecked(ref DataGridView HandledDgView,
 int checkBosPos)
            int checkBosPos)

 
         {
{
 foreach (DataGridViewRow row in HandledDgView.Rows)
            foreach (DataGridViewRow row in HandledDgView.Rows)

 
             {
{
 if (row.Cells[checkBosPos].GetType().Equals(typeof(DataGridViewCheckBoxCell)))
                if (row.Cells[checkBosPos].GetType().Equals(typeof(DataGridViewCheckBoxCell)))

 
                 {
{
 DataGridViewCheckBoxCell CheckBoxCol =
                    DataGridViewCheckBoxCell CheckBoxCol =
 (DataGridViewCheckBoxCell)row.Cells[checkBosPos];
                                (DataGridViewCheckBoxCell)row.Cells[checkBosPos];

 if (CheckBoxCol.Value == null)
                    if (CheckBoxCol.Value == null)

 
                     {
{
 CheckBoxCol.Value = true;
                        CheckBoxCol.Value = true;
 }
                    }
 if (CheckBoxCol.Value.ToString() == "False")//如果被选择了,加入航班执行日期
                    if (CheckBoxCol.Value.ToString() == "False")//如果被选择了,加入航班执行日期

 
                     {
{
 CheckBoxCol.Value = true;
                        CheckBoxCol.Value = true;
 }
                    }
 else
                    else

 
                     {
{
 CheckBoxCol.Value = false;
                        CheckBoxCol.Value = false;
 }
                    }
 }
                }
 }
            }
 }
        }
 
        

 /**//// <summary>
        /**//// <summary>
 /// 反相全选的方法
        /// 反相全选的方法
 /// </summary>
        /// </summary>
 /// <param name="HandledDgView">需要处理的DataGridView</param>
        /// <param name="HandledDgView">需要处理的DataGridView</param>
 /// <param name="checkBosPos">checkbox的位置</param>
        /// <param name="checkBosPos">checkbox的位置</param>
 public static void GetAllCheckBokCheckedReverse(ref DataGridView HandledDgView,
        public static void GetAllCheckBokCheckedReverse(ref DataGridView HandledDgView,
 int checkBosPos)
            int checkBosPos)

 
         {
{
 foreach (DataGridViewRow row in HandledDgView.Rows)
            foreach (DataGridViewRow row in HandledDgView.Rows)

 
             {
{
 DataGridViewCheckBoxCell CheckBoxCol =
                DataGridViewCheckBoxCell CheckBoxCol =
 (DataGridViewCheckBoxCell)row.Cells[checkBosPos];
                    (DataGridViewCheckBoxCell)row.Cells[checkBosPos];
 if (CheckBoxCol.Value == null)
                if (CheckBoxCol.Value == null)

 
                 {
{
 CheckBoxCol.Value = false;
                    CheckBoxCol.Value = false;
 }
                }
 if (CheckBoxCol.Value.ToString() == "False")//如果被选择了,加入航班执行日期
                if (CheckBoxCol.Value.ToString() == "False")//如果被选择了,加入航班执行日期

 
                 {
{
 CheckBoxCol.Value = true;
                    CheckBoxCol.Value = true;
 }
                }
 else
                else

 
                 {
{
 CheckBoxCol.Value = false;
                    CheckBoxCol.Value = false;
 }
                }
 }
            }
 }
        }
 
       

 /**//// <summary>
        /**//// <summary>
 /// 根据传递的参数将一个datagridview中根据需要的值填充好row
        /// 根据传递的参数将一个datagridview中根据需要的值填充好row
 /// </summary>
        /// </summary>
 /// <param name="HandledDgView">需要被处理的datagridview</param>
        /// <param name="HandledDgView">需要被处理的datagridview</param>
 /// <param name="columnCount">DataGridViewRow对象包含的列的数量</param>
        /// <param name="columnCount">DataGridViewRow对象包含的列的数量</param>
 /// <param name="firstColumnType">第一个列的类型是什么</param>
        /// <param name="firstColumnType">第一个列的类型是什么</param>
 /// <param name="value">需要插入到列中的值</param>
        /// <param name="value">需要插入到列中的值</param>
 public static void GenerateDgViewAndInserValueToDgView(ref DataGridView HandledDgView,
        public static void GenerateDgViewAndInserValueToDgView(ref DataGridView HandledDgView,
 int columnCount,
                                                               int columnCount,
 AddSpecialColumnType firstColumnType,
                                                               AddSpecialColumnType firstColumnType,
 object[] value)
                                                               object[] value)

 
         {
{
 //调用本类中的方法产生一个datagridrow
            //调用本类中的方法产生一个datagridrow
 DataGridViewRow tmpRow = GenerateDgvCommonRow(columnCount, firstColumnType);
            DataGridViewRow tmpRow = GenerateDgvCommonRow(columnCount, firstColumnType);
 //定义一个是否加入了特殊列的标志
            //定义一个是否加入了特殊列的标志
 bool IsAddSpecialColumnFlag = false;
            bool IsAddSpecialColumnFlag = false;
 for (int i = 0; i < tmpRow.Cells.Count; i++)
            for (int i = 0; i < tmpRow.Cells.Count; i++)

 
             {
{
 if (i == 0)//当第一列的时候,如果不是textbox,那么不插入值
                if (i == 0)//当第一列的时候,如果不是textbox,那么不插入值

 
                 {
{
 if (firstColumnType == AddSpecialColumnType.TextBox)
                    if (firstColumnType == AddSpecialColumnType.TextBox)
 tmpRow.Cells[i].Value = value[i];
                        tmpRow.Cells[i].Value = value[i];
 else
                    else
 IsAddSpecialColumnFlag = true;
                        IsAddSpecialColumnFlag = true;
 }
                }
 else
                else

 
                 {
{
 if (IsAddSpecialColumnFlag)//如果加入了特殊的列,那么取值就是上一次的
                    if (IsAddSpecialColumnFlag)//如果加入了特殊的列,那么取值就是上一次的
 tmpRow.Cells[i].Value = value[i - 1];
                        tmpRow.Cells[i].Value = value[i - 1];
 else
                    else
 tmpRow.Cells[i].Value = value[i];
                        tmpRow.Cells[i].Value = value[i];
 }
                }
 }
            }
 HandledDgView.Rows.Add(tmpRow);
            HandledDgView.Rows.Add(tmpRow);
 }
        }



 /**//// <summary>
        /**//// <summary>
 /// 根据传递的参数将一个datagridview中根据需要的值填充好row
        /// 根据传递的参数将一个datagridview中根据需要的值填充好row
 /// </summary>
        /// </summary>
 /// <param name="HandledDgView">需要被处理的datagridview</param>
        /// <param name="HandledDgView">需要被处理的datagridview</param>
 /// <param name="columnCount">DataGridViewRow对象包含的列的数量</param>
        /// <param name="columnCount">DataGridViewRow对象包含的列的数量</param>
 /// <param name="firstColumnType">第一个列的类型是什么</param>
        /// <param name="firstColumnType">第一个列的类型是什么</param>
 /// <param name="value">需要插入到列中的值</param>
        /// <param name="value">需要插入到列中的值</param>
 /// <param name="rowColor">此行需要的颜色</param>
        /// <param name="rowColor">此行需要的颜色</param>
 public static void GenerateDgViewAndInserValueToDgView(ref DataGridView HandledDgView,
        public static void GenerateDgViewAndInserValueToDgView(ref DataGridView HandledDgView,
 int columnCount,
                                                               int columnCount,
 AddSpecialColumnType firstColumnType,
                                                               AddSpecialColumnType firstColumnType,
 object[] value, Color rowColor)
                                                               object[] value, Color rowColor)

 
         {
{
 //调用本类中的方法产生一个datagridrow
            //调用本类中的方法产生一个datagridrow
 DataGridViewRow tmpRow = GenerateDgvCommonRow(columnCount, firstColumnType);
            DataGridViewRow tmpRow = GenerateDgvCommonRow(columnCount, firstColumnType);
 //定义一个是否加入了特殊列的标志
            //定义一个是否加入了特殊列的标志
 bool IsAddSpecialColumnFlag = false;
            bool IsAddSpecialColumnFlag = false;
 for (int i = 0; i < tmpRow.Cells.Count; i++)
            for (int i = 0; i < tmpRow.Cells.Count; i++)

 
             {
{
 //当第一列的时候,如果不是textbox,那么不插入值
                //当第一列的时候,如果不是textbox,那么不插入值
 if (i == 0)
                if (i == 0)

 
                 {
{
 if (firstColumnType == AddSpecialColumnType.TextBox)
                    if (firstColumnType == AddSpecialColumnType.TextBox)
 tmpRow.Cells[i].Value = value[i];
                        tmpRow.Cells[i].Value = value[i];
 else
                    else
 IsAddSpecialColumnFlag = true;
                        IsAddSpecialColumnFlag = true;
 }
                }
 else
                else

 
                 {
{
 //如果加入了特殊的列,那么取值就是上一次的
                    //如果加入了特殊的列,那么取值就是上一次的
 if (IsAddSpecialColumnFlag)
                    if (IsAddSpecialColumnFlag)
 tmpRow.Cells[i].Value = value[i - 1];
                        tmpRow.Cells[i].Value = value[i - 1];
 else
                    else
 tmpRow.Cells[i].Value = value[i];
                        tmpRow.Cells[i].Value = value[i];
 }
                }
 }
            }
 tmpRow.DefaultCellStyle.BackColor = rowColor;
            tmpRow.DefaultCellStyle.BackColor = rowColor;
 HandledDgView.Rows.Add(tmpRow);
            HandledDgView.Rows.Add(tmpRow);
 }
        }
 
       

 /**//// <summary>
        /**//// <summary>
 /// 根据传递的参数将一个datagridview中根据需要的值填充好row
        /// 根据传递的参数将一个datagridview中根据需要的值填充好row
 /// </summary>
        /// </summary>
 /// <param name="HandledDgView">需要被处理的datagridview</param>
        /// <param name="HandledDgView">需要被处理的datagridview</param>
 /// <param name="columnCount">DataGridViewRow对象包含的列的数量</param>
        /// <param name="columnCount">DataGridViewRow对象包含的列的数量</param>
 /// <param name="firstColumnType">第一个列的类型是什么</param>
        /// <param name="firstColumnType">第一个列的类型是什么</param>
 /// <param name="value">需要插入到列中的值</param>
        /// <param name="value">需要插入到列中的值</param>
 /// <param name="fontColor">此行字体需要的颜色</param>
        /// <param name="fontColor">此行字体需要的颜色</param>
 public static void GenerateDgViewSetFontColorAndInserValueToDgView(ref DataGridView HandledDgView, int columnCount, AddSpecialColumnType firstColumnType,
        public static void GenerateDgViewSetFontColorAndInserValueToDgView(ref DataGridView HandledDgView, int columnCount, AddSpecialColumnType firstColumnType,
 object[] value, Color fontColor)
                                                               object[] value, Color fontColor)

 
         {
{
 //调用本类中的方法产生一个datagridrow
            //调用本类中的方法产生一个datagridrow
 DataGridViewRow tmpRow = GenerateDgvCommonRow(columnCount, firstColumnType);
            DataGridViewRow tmpRow = GenerateDgvCommonRow(columnCount, firstColumnType);
 //定义一个是否加入了特殊列的标志
            //定义一个是否加入了特殊列的标志
 bool IsAddSpecialColumnFlag = false;
            bool IsAddSpecialColumnFlag = false;
 for (int i = 0; i < tmpRow.Cells.Count; i++)
            for (int i = 0; i < tmpRow.Cells.Count; i++)

 
             {
{
 if (i == 0)//当第一列的时候,如果不是textbox,那么不插入值
                if (i == 0)//当第一列的时候,如果不是textbox,那么不插入值

 
                 {
{
 if (firstColumnType == AddSpecialColumnType.TextBox)
                    if (firstColumnType == AddSpecialColumnType.TextBox)
 tmpRow.Cells[i].Value = value[i];
                        tmpRow.Cells[i].Value = value[i];
 else
                    else
 IsAddSpecialColumnFlag = true;
                        IsAddSpecialColumnFlag = true;
 }
                }
 else
                else

 
                 {
{
 if (IsAddSpecialColumnFlag)//如果加入了特殊的列,那么取值就是上一次的
                    if (IsAddSpecialColumnFlag)//如果加入了特殊的列,那么取值就是上一次的
 tmpRow.Cells[i].Value = value[i - 1];
                        tmpRow.Cells[i].Value = value[i - 1];
 else
                    else
 tmpRow.Cells[i].Value = value[i];
                        tmpRow.Cells[i].Value = value[i];
 }
                }
 }
            }
 tmpRow.DefaultCellStyle.ForeColor = fontColor;
            tmpRow.DefaultCellStyle.ForeColor = fontColor;
 HandledDgView.Rows.Add(tmpRow);
            HandledDgView.Rows.Add(tmpRow);
 }
        }
 
       

 /**//// <summary>
        /**//// <summary>
 /// 向一个datagridview中添加要显示的值
        /// 向一个datagridview中添加要显示的值
 /// </summary>
        /// </summary>
 /// <param name="handler">要被操作的datagridview控件</param>
        /// <param name="handler">要被操作的datagridview控件</param>
 /// <param name="value">行的值</param>
        /// <param name="value">行的值</param>
 public static void InsertValueToDataGridView(ref DataGridView handler,
        public static void InsertValueToDataGridView(ref DataGridView handler,
 string[] value)
                                                     string[] value)

 
         {
{
 handler.Rows.Add(value);
            handler.Rows.Add(value);
 }
        }


 /**//// <summary>
        /**//// <summary>
 /// 设置datagridview的列不排序
        /// 设置datagridview的列不排序
 /// </summary>
        /// </summary>
 /// <param name="handler">需要处理的datagridview</param>
        /// <param name="handler">需要处理的datagridview</param>
 public static void SetColumnNotSortable(ref DataGridView handler)
        public static void SetColumnNotSortable(ref DataGridView handler)

 
         {
{
 foreach (DataGridViewColumn dc in handler.Columns)
            foreach (DataGridViewColumn dc in handler.Columns)

 
             {
{
 dc.SortMode = DataGridViewColumnSortMode.NotSortable;
                dc.SortMode = DataGridViewColumnSortMode.NotSortable;
 }
            }
 }
        }
 #endregion
        #endregion


 设置界面的显示列的一些方法#region 设置界面的显示列的一些方法
        设置界面的显示列的一些方法#region 设置界面的显示列的一些方法


 /**//// <summary>
        /**//// <summary>
 /// 将设置好的DataGridViewColumn[]加入到要显示的DataGridView中
        /// 将设置好的DataGridViewColumn[]加入到要显示的DataGridView中
 /// </summary>
        /// </summary>
 /// <param name="HandledDgView">需要被设置的datagridview</param>
        /// <param name="HandledDgView">需要被设置的datagridview</param>
 /// <param name="columnInfo">列信息</param>
        /// <param name="columnInfo">列信息</param>
 public static void AddSettedColmnInfoToDataGridView(ref DataGridView HandledDgView,
        public static void AddSettedColmnInfoToDataGridView(ref DataGridView HandledDgView,
 DataGridViewColumn[] columnInfo)
                                                     DataGridViewColumn[] columnInfo)

 
         {
{

 测试用的代码,暂时注释#region 测试用的代码,暂时注释
            测试用的代码,暂时注释#region 测试用的代码,暂时注释

 //DataGridViewTextBoxColumn FlightBeginDate = new DataGridViewTextBoxColumn();
            //DataGridViewTextBoxColumn FlightBeginDate = new DataGridViewTextBoxColumn();
 //FlightBeginDate.DataPropertyName = "FlightBeginDate";
            //FlightBeginDate.DataPropertyName = "FlightBeginDate";
 //FlightBeginDate.Name = "FlightBeginDate";
            //FlightBeginDate.Name = "FlightBeginDate";
 //HandledDgView.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] {
            //HandledDgView.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] {
 //FlightBeginDate});
            //FlightBeginDate}); 
 #endregion
            #endregion
 HandledDgView.Columns.AddRange(columnInfo);
            HandledDgView.Columns.AddRange(columnInfo);
 }
        }
 
       

 /**//// <summary>
        /**//// <summary>
 /// 设置界面显示结果的列名字
        /// 设置界面显示结果的列名字
 /// </summary>
        /// </summary>
 public static void SetDataGridViewColumnHeader(ref DataGridView HandledDgView,
        public static void SetDataGridViewColumnHeader(ref DataGridView HandledDgView,
 string[] columnNameArray,
                                                       string[] columnNameArray,
 string[] columnDescriptionArray)
                                                       string[] columnDescriptionArray)

 
         {
{

 从前写死的做法,现在注释了#region 从前写死的做法,现在注释了
            从前写死的做法,现在注释了#region 从前写死的做法,现在注释了

 //HandledDgView.Columns["FlightNo"].HeaderText = "航班号";
            //HandledDgView.Columns["FlightNo"].HeaderText = "航班号";
 //HandledDgView.Columns["FlightBeginDate"].HeaderText = "开始日期";
            //HandledDgView.Columns["FlightBeginDate"].HeaderText = "开始日期";
 //HandledDgView.Columns["FlightEndDate"].HeaderText = "结束日期";
            //HandledDgView.Columns["FlightEndDate"].HeaderText = "结束日期";
 //HandledDgView.Columns["FlightSession"].HeaderText = "班期";
            //HandledDgView.Columns["FlightSession"].HeaderText = "班期";
 //HandledDgView.Columns["FlightSegment"].HeaderText = "航段";
            //HandledDgView.Columns["FlightSegment"].HeaderText = "航段";
 //HandledDgView.Columns["AirPlaneType"].HeaderText = "机型";
            //HandledDgView.Columns["AirPlaneType"].HeaderText = "机型";
 //HandledDgView.Columns["FlightDepTime"].HeaderText = "起飞时间";
            //HandledDgView.Columns["FlightDepTime"].HeaderText = "起飞时间";
 //HandledDgView.Columns["FlightDepSepDay"].HeaderText = "起飞日期间隔";
            //HandledDgView.Columns["FlightDepSepDay"].HeaderText = "起飞日期间隔";
 //HandledDgView.Columns["FlightDestTime"].HeaderText = "到达时间";
            //HandledDgView.Columns["FlightDestTime"].HeaderText = "到达时间";
 //HandledDgView.Columns["FlightDestSepDay"].HeaderText = "到达日期间隔";
            //HandledDgView.Columns["FlightDestSepDay"].HeaderText = "到达日期间隔";
 //HandledDgView.Columns["FlightMaxWeight"].HeaderText = "最大装货量";
            //HandledDgView.Columns["FlightMaxWeight"].HeaderText = "最大装货量";
 //HandledDgView.Columns["FlightControlWeight"].HeaderText = "控制比例";
            //HandledDgView.Columns["FlightControlWeight"].HeaderText = "控制比例";
 //HandledDgView.Columns["FlightOutWeight"].HeaderText = "开放比例";
            //HandledDgView.Columns["FlightOutWeight"].HeaderText = "开放比例";
 //HandledDgView.Columns["FlightFdepArea"].HeaderText = "起飞站国别";
            //HandledDgView.Columns["FlightFdepArea"].HeaderText = "起飞站国别";
 //HandledDgView.Columns["FlightFdestArea"].HeaderText = "到达站国别";
            //HandledDgView.Columns["FlightFdestArea"].HeaderText = "到达站国别";
 //HandledDgView.Columns["FlightRouting"].HeaderText = "航程";
            //HandledDgView.Columns["FlightRouting"].HeaderText = "航程"; 
 #endregion
            #endregion
 for (int i = 0; i < columnNameArray.Length; i++)
            for (int i = 0; i < columnNameArray.Length; i++)

 
             {
{
 HandledDgView.Columns[columnNameArray[i]].HeaderText = columnDescriptionArray[i];
                HandledDgView.Columns[columnNameArray[i]].HeaderText = columnDescriptionArray[i];
 }
            }
 }
        }
 
        

 /**//// <summary>
        /**//// <summary>
 /// 设置界面显示结果的列的显示顺序,提供一个使用列名字作为参数的重载
        /// 设置界面显示结果的列的显示顺序,提供一个使用列名字作为参数的重载

 /// </summary>
        /// </summary>
 /// <param name="HandledDgView">需要被设置的DataGridView</param>
        /// <param name="HandledDgView">需要被设置的DataGridView</param>
 /// <param name="columnNameArray">包含了这个DataGridView需要的列名字的数组</param>
        /// <param name="columnNameArray">包含了这个DataGridView需要的列名字的数组</param>
 public static void SetDataGridViewColumnHeadSequence(ref DataGridView HandledDgView,
        public static void SetDataGridViewColumnHeadSequence(ref DataGridView HandledDgView,
 string[] columnNameArray)
                                                             string[] columnNameArray)

 
         {
{
 for (int i = 0; i < columnNameArray.Length; i++)//利用名字数组作循环
            for (int i = 0; i < columnNameArray.Length; i++)//利用名字数组作循环

 
             {
{
 HandledDgView.Columns[columnNameArray[i]].DisplayIndex = i;
                HandledDgView.Columns[columnNameArray[i]].DisplayIndex = i;
 }
            }

 从前写死的做法,暂时注释了#region 从前写死的做法,暂时注释了
            从前写死的做法,暂时注释了#region 从前写死的做法,暂时注释了

 //HandledDgView.Columns["FlightNo"].DisplayIndex = 0;
            //HandledDgView.Columns["FlightNo"].DisplayIndex = 0;
 //HandledDgView.Columns["FlightBeginDate"].DisplayIndex = 1;
            //HandledDgView.Columns["FlightBeginDate"].DisplayIndex = 1;
 //HandledDgView.Columns["FlightEndDate"].DisplayIndex = 2;
            //HandledDgView.Columns["FlightEndDate"].DisplayIndex = 2;
 //HandledDgView.Columns["FlightSession"].DisplayIndex = 3;
            //HandledDgView.Columns["FlightSession"].DisplayIndex = 3;
 //HandledDgView.Columns["FlightSegment"].DisplayIndex = 4;
            //HandledDgView.Columns["FlightSegment"].DisplayIndex = 4;
 //HandledDgView.Columns["AirPlaneType"].DisplayIndex = 5;
            //HandledDgView.Columns["AirPlaneType"].DisplayIndex = 5;
 //HandledDgView.Columns["FlightDepTime"].DisplayIndex = 6;
            //HandledDgView.Columns["FlightDepTime"].DisplayIndex = 6;
 //HandledDgView.Columns["FlightDepSepDay"].DisplayIndex = 7;
            //HandledDgView.Columns["FlightDepSepDay"].DisplayIndex = 7;
 //HandledDgView.Columns["FlightDestTime"].DisplayIndex = 8;
            //HandledDgView.Columns["FlightDestTime"].DisplayIndex = 8;
 //HandledDgView.Columns["FlightDestSepDay"].DisplayIndex = 9;
            //HandledDgView.Columns["FlightDestSepDay"].DisplayIndex = 9;
 //HandledDgView.Columns["FlightMaxWeight"].DisplayIndex = 10;
            //HandledDgView.Columns["FlightMaxWeight"].DisplayIndex = 10;
 //HandledDgView.Columns["FlightControlWeight"].DisplayIndex = 11;
            //HandledDgView.Columns["FlightControlWeight"].DisplayIndex = 11;
 //HandledDgView.Columns["FlightOutWeight"].DisplayIndex = 12;
            //HandledDgView.Columns["FlightOutWeight"].DisplayIndex = 12;
 //HandledDgView.Columns["FlightFdepArea"].DisplayIndex = 13;
            //HandledDgView.Columns["FlightFdepArea"].DisplayIndex = 13;
 //HandledDgView.Columns["FlightFdestArea"].DisplayIndex = 14;
            //HandledDgView.Columns["FlightFdestArea"].DisplayIndex = 14;
 //HandledDgView.Columns["FlightRouting"].DisplayIndex = 15;
            //HandledDgView.Columns["FlightRouting"].DisplayIndex = 15; 
 #endregion
            #endregion
 }
        }
 
        

 /**//// <summary>
        /**//// <summary>
 ///返回一个定义了DataGridViewColumn的名字和数据绑定字段的数组
        ///返回一个定义了DataGridViewColumn的名字和数据绑定字段的数组

 /// 用于DataGridView的列显示
        /// 用于DataGridView的列显示
 /// </summary>
        /// </summary>
 /// <param name="columnNameArray">列名字的数组</param>
        /// <param name="columnNameArray">列名字的数组</param>
 /// <param name="specialColumnIndex">需要特殊设置的列宽的列的索引和宽度</param>
        /// <param name="specialColumnIndex">需要特殊设置的列宽的列的索引和宽度</param>
 /// <returns>定义好的DataGridViewColumn对象数组</returns>
        /// <returns>定义好的DataGridViewColumn对象数组</returns>
 public static DataGridViewColumn[] SetDgViewColumnProperty(string[] columnNameArray,
        public static DataGridViewColumn[] SetDgViewColumnProperty(string[] columnNameArray,
 System.Collections.Hashtable specialColumnIndex)
                                                                   System.Collections.Hashtable specialColumnIndex)

 
         {
{

 //然后获得数组的边界,定义返回的DataGridViewColumn的数组范围
            //然后获得数组的边界,定义返回的DataGridViewColumn的数组范围

 int arrCount = columnNameArray.Length;
            int arrCount = columnNameArray.Length;
 //定义返回的DataGridViewColumn
            //定义返回的DataGridViewColumn
 DataGridViewColumn[] resultColumn = new DataGridViewColumn[arrCount];
            DataGridViewColumn[] resultColumn = new DataGridViewColumn[arrCount];
 //设置一个是否需要进行特殊列宽度设置的标志
            //设置一个是否需要进行特殊列宽度设置的标志

 bool SpecialWidthFlag = false;
            bool SpecialWidthFlag = false;
 if (specialColumnIndex == null)
            if (specialColumnIndex == null)
 SpecialWidthFlag = false;
                SpecialWidthFlag = false;
 else
            else
 SpecialWidthFlag = true;
                SpecialWidthFlag = true;
 //bool SpecialWidthFlag = specialColumnIndex.Equals(null)?false:true;
            //bool SpecialWidthFlag = specialColumnIndex.Equals(null)?false:true;
 //循环数组
            //循环数组
 for (int i = 0; i < columnNameArray.Length; i++)
            for (int i = 0; i < columnNameArray.Length; i++)

 
             {
{
 DataGridViewTextBoxColumn tmpColumn = new DataGridViewTextBoxColumn();
                DataGridViewTextBoxColumn tmpColumn = new DataGridViewTextBoxColumn();
 //设置列对应的数据绑定的名字
                //设置列对应的数据绑定的名字

 tmpColumn.DataPropertyName = columnNameArray[i].Trim().ToUpper();
                tmpColumn.DataPropertyName = columnNameArray[i].Trim().ToUpper();
 //设置列的名字
                //设置列的名字
 tmpColumn.Name = columnNameArray[i].Trim().ToUpper();
                tmpColumn.Name = columnNameArray[i].Trim().ToUpper();
 if (SpecialWidthFlag)//如果需要特殊设置
                if (SpecialWidthFlag)//如果需要特殊设置

 
                 {
{
 if (specialColumnIndex.ContainsKey(i))//如果是特殊需要设置的列,设置为自定义的宽度
                    if (specialColumnIndex.ContainsKey(i))//如果是特殊需要设置的列,设置为自定义的宽度

 
                     {
{
 tmpColumn.Width = (int)specialColumnIndex[i];
                        tmpColumn.Width = (int)specialColumnIndex[i];
 if ((int)specialColumnIndex[i] == 0)//如果此列的宽度为0,说明不显示
                        if ((int)specialColumnIndex[i] == 0)//如果此列的宽度为0,说明不显示
 tmpColumn.Visible = false;
                            tmpColumn.Visible = false;
 }
                    }
 }
                }
 else
                else
 tmpColumn.Width = commonWidth;//其余的采用普通宽度
                    tmpColumn.Width = commonWidth;//其余的采用普通宽度



 以前写死的,现在修改为使用list进行查找#region 以前写死的,现在修改为使用list进行查找
                以前写死的,现在修改为使用list进行查找#region 以前写死的,现在修改为使用list进行查找
 //if (i==7||i==9||i==10||i==13||i==14)
                //if (i==7||i==9||i==10||i==13||i==14)
 //{
                //{
 //    tmpColumn.Width = 110;
                //    tmpColumn.Width = 110;
 //}
                //}
 //else
                //else
 //{
                //{
 //    tmpColumn.Width = 80;
                //    tmpColumn.Width = 80;
 //}
                //} 

 /**/////判断是否有需要特殊设置的列
                /**/////判断是否有需要特殊设置的列

 //if (specialColumnIndex.Contains(i))//如果是特殊需要设置的列,设置为长宽度
                //if (specialColumnIndex.Contains(i))//如果是特殊需要设置的列,设置为长宽度
 //    tmpColumn.Width = 110;
                //    tmpColumn.Width = 110;
 //else
                //else
 //    tmpColumn.Width = commonWidth;//其余的采用普通宽度
                //    tmpColumn.Width = commonWidth;//其余的采用普通宽度

 #endregion
                #endregion
 resultColumn[i] = tmpColumn;
                resultColumn[i] = tmpColumn;
 }
            }
 //返回结果
            //返回结果
 return resultColumn;
            return resultColumn;
 }
        }
 
       

 /**//// <summary>
        /**//// <summary>
 /// 设置界面显示结果的列名字
        /// 设置界面显示结果的列名字
 /// </summary>
        /// </summary>
 public static void SetDataGridViewColumnHeader(ref DataGridView HandledDgView,
        public static void SetDataGridViewColumnHeader(ref DataGridView HandledDgView,
 string[] columnNameArray,
                                                       string[] columnNameArray,
 string[] columnDescriptionArray,
                                                       string[] columnDescriptionArray,
 AddSpecialColumnType columnType)
                                                       AddSpecialColumnType columnType)

 
         {
{

 从前写死的做法,现在注释了#region 从前写死的做法,现在注释了
            从前写死的做法,现在注释了#region 从前写死的做法,现在注释了

 //HandledDgView.Columns["FlightNo"].HeaderText = "航班号";
            //HandledDgView.Columns["FlightNo"].HeaderText = "航班号";
 //HandledDgView.Columns["FlightBeginDate"].HeaderText = "开始日期";
            //HandledDgView.Columns["FlightBeginDate"].HeaderText = "开始日期";
 //HandledDgView.Columns["FlightEndDate"].HeaderText = "结束日期";
            //HandledDgView.Columns["FlightEndDate"].HeaderText = "结束日期";
 //HandledDgView.Columns["FlightSession"].HeaderText = "班期";
            //HandledDgView.Columns["FlightSession"].HeaderText = "班期";
 //HandledDgView.Columns["FlightSegment"].HeaderText = "航段";
            //HandledDgView.Columns["FlightSegment"].HeaderText = "航段";
 //HandledDgView.Columns["AirPlaneType"].HeaderText = "机型";
            //HandledDgView.Columns["AirPlaneType"].HeaderText = "机型";
 //HandledDgView.Columns["FlightDepTime"].HeaderText = "起飞时间";
            //HandledDgView.Columns["FlightDepTime"].HeaderText = "起飞时间";
 //HandledDgView.Columns["FlightDepSepDay"].HeaderText = "起飞日期间隔";
            //HandledDgView.Columns["FlightDepSepDay"].HeaderText = "起飞日期间隔";
 //HandledDgView.Columns["FlightDestTime"].HeaderText = "到达时间";
            //HandledDgView.Columns["FlightDestTime"].HeaderText = "到达时间";
 //HandledDgView.Columns["FlightDestSepDay"].HeaderText = "到达日期间隔";
            //HandledDgView.Columns["FlightDestSepDay"].HeaderText = "到达日期间隔";
 //HandledDgView.Columns["FlightMaxWeight"].HeaderText = "最大装货量";
            //HandledDgView.Columns["FlightMaxWeight"].HeaderText = "最大装货量";
 //HandledDgView.Columns["FlightControlWeight"].HeaderText = "控制比例";
            //HandledDgView.Columns["FlightControlWeight"].HeaderText = "控制比例";
 //HandledDgView.Columns["FlightOutWeight"].HeaderText = "开放比例";
            //HandledDgView.Columns["FlightOutWeight"].HeaderText = "开放比例";
 //HandledDgView.Columns["FlightFdepArea"].HeaderText = "起飞站国别";
            //HandledDgView.Columns["FlightFdepArea"].HeaderText = "起飞站国别";
 //HandledDgView.Columns["FlightFdestArea"].HeaderText = "到达站国别";
            //HandledDgView.Columns["FlightFdestArea"].HeaderText = "到达站国别";
 //HandledDgView.Columns["FlightRouting"].HeaderText = "航程";
            //HandledDgView.Columns["FlightRouting"].HeaderText = "航程"; 
 #endregion
            #endregion
 for (int i = 0; i < columnNameArray.Length; i++)
            for (int i = 0; i < columnNameArray.Length; i++)

 
             {
{
 HandledDgView.Columns[columnNameArray[i]].HeaderText = columnDescriptionArray[i];
                HandledDgView.Columns[columnNameArray[i]].HeaderText = columnDescriptionArray[i];
 }
            }
 }
        }
 
       

 /**//// <summary>
        /**//// <summary>
 /// 设置界面显示结果的列的显示顺序,提供一个使用列名字作为参数的重载
        /// 设置界面显示结果的列的显示顺序,提供一个使用列名字作为参数的重载

 /// </summary>
        /// </summary>
 /// <param name="HandledDgView">需要被设置的DataGridView</param>
        /// <param name="HandledDgView">需要被设置的DataGridView</param>
 /// <param name="columnNameArray">包含了这个DataGridView需要的列名字的数组</param>
        /// <param name="columnNameArray">包含了这个DataGridView需要的列名字的数组</param>
 /// <param name="columnType">需要加入的特殊列的类型</param>
        /// <param name="columnType">需要加入的特殊列的类型</param>
 public static void SetDataGridViewColumnHeadSequence(ref DataGridView HandledDgView,
        public static void SetDataGridViewColumnHeadSequence(ref DataGridView HandledDgView,
 string[] columnNameArray,
                                                             string[] columnNameArray,
 AddSpecialColumnType columnType)
                                                             AddSpecialColumnType columnType)

 
         {
{
 for (int i = 0; i < columnNameArray.Length; i++)//利用名字数组作循环
            for (int i = 0; i < columnNameArray.Length; i++)//利用名字数组作循环

 
             {
{
 HandledDgView.Columns[columnNameArray[i]].DisplayIndex = i + 1;
                HandledDgView.Columns[columnNameArray[i]].DisplayIndex = i + 1;
 }
            }

 从前写死的做法,暂时注释了#region 从前写死的做法,暂时注释了
            从前写死的做法,暂时注释了#region 从前写死的做法,暂时注释了

 //HandledDgView.Columns["FlightNo"].DisplayIndex = 0;
            //HandledDgView.Columns["FlightNo"].DisplayIndex = 0;
 //HandledDgView.Columns["FlightBeginDate"].DisplayIndex = 1;
            //HandledDgView.Columns["FlightBeginDate"].DisplayIndex = 1;
 //HandledDgView.Columns["FlightEndDate"].DisplayIndex = 2;
            //HandledDgView.Columns["FlightEndDate"].DisplayIndex = 2;
 //HandledDgView.Columns["FlightSession"].DisplayIndex = 3;
            //HandledDgView.Columns["FlightSession"].DisplayIndex = 3;
 //HandledDgView.Columns["FlightSegment"].DisplayIndex = 4;
            //HandledDgView.Columns["FlightSegment"].DisplayIndex = 4;
 //HandledDgView.Columns["AirPlaneType"].DisplayIndex = 5;
            //HandledDgView.Columns["AirPlaneType"].DisplayIndex = 5;
 //HandledDgView.Columns["FlightDepTime"].DisplayIndex = 6;
            //HandledDgView.Columns["FlightDepTime"].DisplayIndex = 6;
 //HandledDgView.Columns["FlightDepSepDay"].DisplayIndex = 7;
            //HandledDgView.Columns["FlightDepSepDay"].DisplayIndex = 7;
 //HandledDgView.Columns["FlightDestTime"].DisplayIndex = 8;
            //HandledDgView.Columns["FlightDestTime"].DisplayIndex = 8;
 //HandledDgView.Columns["FlightDestSepDay"].DisplayIndex = 9;
            //HandledDgView.Columns["FlightDestSepDay"].DisplayIndex = 9;
 //HandledDgView.Columns["FlightMaxWeight"].DisplayIndex = 10;
            //HandledDgView.Columns["FlightMaxWeight"].DisplayIndex = 10;
 //HandledDgView.Columns["FlightControlWeight"].DisplayIndex = 11;
            //HandledDgView.Columns["FlightControlWeight"].DisplayIndex = 11;
 //HandledDgView.Columns["FlightOutWeight"].DisplayIndex = 12;
            //HandledDgView.Columns["FlightOutWeight"].DisplayIndex = 12;
 //HandledDgView.Columns["FlightFdepArea"].DisplayIndex = 13;
            //HandledDgView.Columns["FlightFdepArea"].DisplayIndex = 13;
 //HandledDgView.Columns["FlightFdestArea"].DisplayIndex = 14;
            //HandledDgView.Columns["FlightFdestArea"].DisplayIndex = 14;
 //HandledDgView.Columns["FlightRouting"].DisplayIndex = 15;
            //HandledDgView.Columns["FlightRouting"].DisplayIndex = 15; 
 #endregion
            #endregion
 }
        }
 
       

 /**//// <summary>
        /**//// <summary>
 ///返回一个定义了DataGridViewColumn的名字和数据绑定字段的数组
        ///返回一个定义了DataGridViewColumn的名字和数据绑定字段的数组

 /// 用于DataGridView的列显示
        /// 用于DataGridView的列显示
 /// </summary>
        /// </summary>
 /// <param name="columnNameArray">列名字的数组</param>
        /// <param name="columnNameArray">列名字的数组</param>
 /// <param name="specialColumnIndex">需要特殊设置的列宽的列的索引和宽度</param>
        /// <param name="specialColumnIndex">需要特殊设置的列宽的列的索引和宽度</param>
 /// <param name="columnType">加入的特殊列的类型</param>
        /// <param name="columnType">加入的特殊列的类型</param>
 /// <returns>定义好的DataGridViewColumn对象数组</returns>
        /// <returns>定义好的DataGridViewColumn对象数组</returns>
 public static DataGridViewColumn[] SetDgViewColumnProperty(string[] columnNameArray,
        public static DataGridViewColumn[] SetDgViewColumnProperty(string[] columnNameArray,
 System.Collections.Hashtable specialColumnIndex,
                                                                   System.Collections.Hashtable specialColumnIndex,
 AddSpecialColumnType columnType)
                                                                   AddSpecialColumnType columnType)

 
         {
{

 //然后获得数组的边界,定义返回的DataGridViewColumn的数组范围
            //然后获得数组的边界,定义返回的DataGridViewColumn的数组范围

 int arrCount = columnNameArray.Length;
            int arrCount = columnNameArray.Length;
 //定义返回的DataGridViewColumn
            //定义返回的DataGridViewColumn
 DataGridViewColumn[] resultColumn = new DataGridViewColumn[arrCount + 1];
            DataGridViewColumn[] resultColumn = new DataGridViewColumn[arrCount + 1];
 //设置一个是否需要进行特殊列宽度设置的标志
            //设置一个是否需要进行特殊列宽度设置的标志

 bool SpecialWidthFlag = false;
            bool SpecialWidthFlag = false;
 if (specialColumnIndex == null)
            if (specialColumnIndex == null)
 SpecialWidthFlag = false;
                SpecialWidthFlag = false;
 else
            else
 SpecialWidthFlag = true;
                SpecialWidthFlag = true;

 resultColumn[0] = GenerateSpecialColumn(columnType);
            resultColumn[0] = GenerateSpecialColumn(columnType);
 //bool SpecialWidthFlag = specialColumnIndex.Equals(null)?false:true;
            //bool SpecialWidthFlag = specialColumnIndex.Equals(null)?false:true;
 //循环数组
            //循环数组
 for (int i = 0; i < columnNameArray.Length; i++)
            for (int i = 0; i < columnNameArray.Length; i++)

 
             {
{
 DataGridViewTextBoxColumn tmpColumn = new DataGridViewTextBoxColumn();
                DataGridViewTextBoxColumn tmpColumn = new DataGridViewTextBoxColumn();
 //设置列对应的数据绑定的名字
                //设置列对应的数据绑定的名字

 tmpColumn.DataPropertyName = columnNameArray[i].Trim().ToUpper();
                tmpColumn.DataPropertyName = columnNameArray[i].Trim().ToUpper();
 //设置列的名字
                //设置列的名字
 tmpColumn.Name = columnNameArray[i].Trim().ToUpper();
                tmpColumn.Name = columnNameArray[i].Trim().ToUpper();
 if (SpecialWidthFlag)//如果需要特殊设置
                if (SpecialWidthFlag)//如果需要特殊设置

 
                 {
{
 if (specialColumnIndex.ContainsKey(i))//如果是特殊需要设置的列,设置为自定义的宽度
                    if (specialColumnIndex.ContainsKey(i))//如果是特殊需要设置的列,设置为自定义的宽度

 
                     {
{
 tmpColumn.Width = (int)specialColumnIndex[i];
                        tmpColumn.Width = (int)specialColumnIndex[i];
 }
                    }
 }
                }
 else
                else
 tmpColumn.Width = commonWidth;//其余的采用普通宽度
                    tmpColumn.Width = commonWidth;//其余的采用普通宽度



 以前写死的,现在修改为使用list进行查找#region 以前写死的,现在修改为使用list进行查找
                以前写死的,现在修改为使用list进行查找#region 以前写死的,现在修改为使用list进行查找
 //if (i==7||i==9||i==10||i==13||i==14)
                //if (i==7||i==9||i==10||i==13||i==14)
 //{
                //{
 //    tmpColumn.Width = 110;
                //    tmpColumn.Width = 110;
 //}
                //}
 //else
                //else
 //{
                //{
 //    tmpColumn.Width = 80;
                //    tmpColumn.Width = 80;
 //}
                //} 

 /**/////判断是否有需要特殊设置的列
                /**/////判断是否有需要特殊设置的列

 //if (specialColumnIndex.Contains(i))//如果是特殊需要设置的列,设置为长宽度
                //if (specialColumnIndex.Contains(i))//如果是特殊需要设置的列,设置为长宽度
 //    tmpColumn.Width = 110;
                //    tmpColumn.Width = 110;
 //else
                //else
 //    tmpColumn.Width = commonWidth;//其余的采用普通宽度
                //    tmpColumn.Width = commonWidth;//其余的采用普通宽度

 #endregion
                #endregion
 resultColumn[i + 1] = tmpColumn;
                resultColumn[i + 1] = tmpColumn;
 }
            }
 //返回结果
            //返回结果
 return resultColumn;
            return resultColumn;
 }
        }
 
       

 /**//// <summary>
        /**//// <summary>
 /// 根据需要加入的特殊列的类型,产生一个特殊列
        /// 根据需要加入的特殊列的类型,产生一个特殊列
 /// </summary>
        /// </summary>
 /// <param name="columnType">要加入的特殊列的类型</param>
        /// <param name="columnType">要加入的特殊列的类型</param>
 /// <returns>返回一个构造好的特殊列</returns>
        /// <returns>返回一个构造好的特殊列</returns>
 private static DataGridViewColumn GenerateSpecialColumn(AddSpecialColumnType columnType)
        private static DataGridViewColumn GenerateSpecialColumn(AddSpecialColumnType columnType)

 
         {
{
 DataGridViewColumn specialColumn = new DataGridViewColumn();
            DataGridViewColumn specialColumn = new DataGridViewColumn();
 switch (columnType)
            switch (columnType)

 
             {
{
 case AddSpecialColumnType.CheckBox:
                case AddSpecialColumnType.CheckBox:
 DataGridViewCheckBoxColumn checkColumn = new DataGridViewCheckBoxColumn();
                    DataGridViewCheckBoxColumn checkColumn = new DataGridViewCheckBoxColumn();
 checkColumn.Frozen = true;
                    checkColumn.Frozen = true;
 checkColumn.Width = 30;
                    checkColumn.Width = 30;
 checkColumn.TrueValue = "true";
                    checkColumn.TrueValue = "true";
 checkColumn.FalseValue = "false";
                    checkColumn.FalseValue = "false";
 specialColumn = checkColumn;
                    specialColumn = checkColumn;
 break;
                    break;
 case AddSpecialColumnType.ComboBox:
                case AddSpecialColumnType.ComboBox:
 DataGridViewComboBoxColumn comboColumn = new DataGridViewComboBoxColumn();
                    DataGridViewComboBoxColumn comboColumn = new DataGridViewComboBoxColumn();
 comboColumn.Frozen = true;
                    comboColumn.Frozen = true;
 comboColumn.Width = 30;
                    comboColumn.Width = 30;
 specialColumn = comboColumn;
                    specialColumn = comboColumn;
 break;
                    break;
 default:
                default:
 DataGridViewCheckBoxColumn defaultCheckColumn = new DataGridViewCheckBoxColumn();
                    DataGridViewCheckBoxColumn defaultCheckColumn = new DataGridViewCheckBoxColumn();
 defaultCheckColumn.Frozen = true;
                    defaultCheckColumn.Frozen = true;
 defaultCheckColumn.Width = 30;
                    defaultCheckColumn.Width = 30;
 defaultCheckColumn.TrueValue = "true";
                    defaultCheckColumn.TrueValue = "true";
 defaultCheckColumn.FalseValue = "false";
                    defaultCheckColumn.FalseValue = "false";
 specialColumn = defaultCheckColumn;
                    specialColumn = defaultCheckColumn;
 break;
                    break;
 }
            }
 return specialColumn;
            return specialColumn;
 }
        }

 
        

 /**//// <summary>
        /**//// <summary>
 /// 设置需要特别显示宽度的列的index和需要设置的宽度
        /// 设置需要特别显示宽度的列的index和需要设置的宽度
 /// </summary>
        /// </summary>
 /// <param name="ColumnIndex">包含了需要特殊设置的列的索引</param>
        /// <param name="ColumnIndex">包含了需要特殊设置的列的索引</param>
 /// <param name="ColumnWidth">包含了需要特殊设置的列的宽度</param>
        /// <param name="ColumnWidth">包含了需要特殊设置的列的宽度</param>
 /// <returns>需要特殊设置列的索引和设置的宽度</returns>
        /// <returns>需要特殊设置列的索引和设置的宽度</returns>
 public static System.Collections.Hashtable WidthEnlargeColumn(int[] ColumnIndex,
        public static System.Collections.Hashtable WidthEnlargeColumn(int[] ColumnIndex,
 int[] ColumnWidth)
                                                                      int[] ColumnWidth)

 
         {
{

 以前的做法,现在注释了#region 以前的做法,现在注释了
            以前的做法,现在注释了#region 以前的做法,现在注释了

 //int[] ColumnIndex = { 7, 9, 10, 13, 14 };
            //int[] ColumnIndex = { 7, 9, 10, 13, 14 };
 //List<int> specialColumnIndex = new List<int>();
            //List<int> specialColumnIndex = new List<int>();
 //specialColumnIndex.AddRange(ColumnIndex);
            //specialColumnIndex.AddRange(ColumnIndex);
 //return (specialColumnIndex);
            //return (specialColumnIndex); 
 #endregion
            #endregion
 System.Collections.Hashtable resultTable = new System.Collections.Hashtable();
            System.Collections.Hashtable resultTable = new System.Collections.Hashtable();
 if (ColumnIndex.Length != ColumnWidth.Length)//如果列索引与列的宽度的数组中包含的数量不相等,返回null
            if (ColumnIndex.Length != ColumnWidth.Length)//如果列索引与列的宽度的数组中包含的数量不相等,返回null

 
             {
{
 //return new System.Collections.Hashtable();
                //return new System.Collections.Hashtable();
 return resultTable;
                return resultTable;
 }
            }

 //循环操作,将索引和对应的宽度加入到返回的Hashtable中
            //循环操作,将索引和对应的宽度加入到返回的Hashtable中

 for (int i = 0; i < ColumnIndex.Length; i++)
            for (int i = 0; i < ColumnIndex.Length; i++)

 
             {
{
 resultTable.Add(ColumnIndex[i], ColumnWidth[i]);
                resultTable.Add(ColumnIndex[i], ColumnWidth[i]);
 }
            }
 return resultTable;
            return resultTable;
 }
        }


 #endregion
        #endregion


 一些关于文本框输入的可输入性的共用方法#region 一些关于文本框输入的可输入性的共用方法
        一些关于文本框输入的可输入性的共用方法#region 一些关于文本框输入的可输入性的共用方法

 /**//// <summary>
        /**//// <summary>
 /// 只输入字母的判断
        /// 只输入字母的判断
 /// ASC://48-57(数字),65-90(字母)
        /// ASC://48-57(数字),65-90(字母)
 /// </summary>
        /// </summary>
 /// <param name="e">按键的对象</param>
        /// <param name="e">按键的对象</param>
 /// <returns>符合要求返回true,否则返回false</returns>
        /// <returns>符合要求返回true,否则返回false</returns>
 public static bool InputOnlyLetterAndInteger(char e)
        public static bool InputOnlyLetterAndInteger(char e)

 
         {
{
 if ((e >= 65 && e <= 90) ||
            if ((e >= 65 && e <= 90) ||
 (e >= 48 && e <= 57) || e == 8 ||
                (e >= 48 && e <= 57) || e == 8 ||
 (e >= 97 && e <= 122) || (e == (char)Keys.Back))
                (e >= 97 && e <= 122) || (e == (char)Keys.Back))
 return true;
                return true;
 else
            else
 return false;
                return false;
 }
        }

 /**//// <summary>
        /**//// <summary>
 /// 只输入字母和数字还有-/的判断
        /// 只输入字母和数字还有-/的判断

 /// ASC://48-57(数字),65-90(字母)
        /// ASC://48-57(数字),65-90(字母)
 /// </summary>
        /// </summary>
 /// <param name="e">按键的对象</param>
        /// <param name="e">按键的对象</param>
 /// <returns>符合要求返回true,否则返回false</returns>
        /// <returns>符合要求返回true,否则返回false</returns>
 public static bool InputOnlyLetterAndIntegerAndSpeChar(char e)
        public static bool InputOnlyLetterAndIntegerAndSpeChar(char e)

 
         {
{
 if ((e >= 65 && e <= 90) ||
            if ((e >= 65 && e <= 90) ||
 (e >= 48 && e <= 57) || e == 8 || e == 45 || e == 47 ||
                (e >= 48 && e <= 57) || e == 8 || e == 45 || e == 47 ||
 (e >= 97 && e <= 122) || (e == (char)Keys.Back))
                (e >= 97 && e <= 122) || (e == (char)Keys.Back))
 return true;
                return true;
 else
            else
 return false;
                return false;
 }
        }

 /**//// <summary>
        /**//// <summary>
 /// 只输入字母的判断
        /// 只输入字母的判断
 /// </summary>
        /// </summary>
 /// <param name="e">按键的对象</param>
        /// <param name="e">按键的对象</param>
 /// <returns>符合要求返回true,否则返回false</returns>
        /// <returns>符合要求返回true,否则返回false</returns>
 public static bool InputOnlyLetter(char e)
        public static bool InputOnlyLetter(char e)

 
         {
{
 if ((e >= 65 && e <= 90) ||
            if ((e >= 65 && e <= 90) ||
 e == 8 ||
                 e == 8 ||
 (e >= 97 && e <= 122) || (e == (char)Keys.Back))
                (e >= 97 && e <= 122) || (e == (char)Keys.Back))
 return true;
                return true;
 else
            else
 return false;
                return false;
 }
        }

 /**//// <summary>
        /**//// <summary>
 /// 只输入数字和小数点的判断
        /// 只输入数字和小数点的判断
 /// </summary>
        /// </summary>
 /// <param name="e">按键的对象</param>
        /// <param name="e">按键的对象</param>
 /// <returns>符合要求返回true,否则返回false</returns>
        /// <returns>符合要求返回true,否则返回false</returns>
 public static bool InputOnlyNumberAndDot(char e)
        public static bool InputOnlyNumberAndDot(char e)

 
         {
{
 if ((e >= 48 && e <= 57) || (e == 46) || (e == (char)Keys.Back))
            if ((e >= 48 && e <= 57) || (e == 46) || (e == (char)Keys.Back))
 return true;
                return true;
 else
            else
 return false;
                return false;
 }
        }

 /**//// <summary>
        /**//// <summary>
 /// 只输入数字的判断
        /// 只输入数字的判断
 /// </summary>
        /// </summary>
 /// <param name="e">按键的对象</param>
        /// <param name="e">按键的对象</param>
 /// <returns>符合要求返回true,否则返回false</returns>
        /// <returns>符合要求返回true,否则返回false</returns>
 public static bool InputOnlyNumber(char e)
        public static bool InputOnlyNumber(char e)

 
         {
{
 if ((e >= 48 && e <= 57) || (e == (char)Keys.Back))
            if ((e >= 48 && e <= 57) || (e == (char)Keys.Back))
 return true;
                return true;
 else
            else
 return false;
                return false;
 }
        }


 #endregion
        #endregion 
	posted on 
2009-05-19 16:59 
Kein 
阅读(
591) 
评论() 
 
收藏 
举报