Infragistics控件使用-UltraGrid

2006-09-02  ayi

Infragistics控件使用-UltraGrid

                                      

1 UltraGrid风格设置函数
public static void ColorGrid(ref Infragistics.Win.UltraWinGrid.UltraGrid ug)
  {
   //标题
   ug.DisplayLayout.CaptionAppearance.TextHAlign = Infragistics.Win.HAlign.Left;
   ug.DisplayLayout.CaptionAppearance.BackColor = Color.LightSteelBlue;

   //边框显示
   ug.DisplayLayout.BorderStyle = Infragistics.Win.UIElementBorderStyle.Solid;

   //背景色
   ug.DisplayLayout.Appearance.BackColor = Color.White;
   
   //默认颜色设置
   ug.DisplayLayout.Override.HeaderAppearance.BackColor = Color.LightSteelBlue;//列
   ug.DisplayLayout.Override.RowSelectorAppearance.BackColor = Color.LightSteelBlue;//行

   //选中颜色设置
   ug.DisplayLayout.Override.SelectedCellAppearance.BackColor = Color.SteelBlue;//选中单元格
   ug.DisplayLayout.Override.SelectedRowAppearance.BackColor = Color.SteelBlue;//选中行

   //ActiveRowx颜色设置
   ug.DisplayLayout.Override.ActiveRowAppearance.BackColor = Color.SteelBlue;
  }

2 UltraGrid 删除选中的行
this.ultraGrid1.DeleteSelectedRows(false);

3 委托
this.ultraGrid1.AfterCellUpdate -= new Infragistics.Win.UltraWinGrid.CellEventHandler(this.ultraGrid1_AfterCellUpdate);
      this.ultraGrid1.Rows[0].Cells["字段名"].Value = "";
      this.ultraGrid1.AfterCellUpdate += new Infragistics.Win.UltraWinGrid.CellEventHandler(this.ultraGrid1_AfterCellUpdate);

4 判断
e.Cell.Column.Key == "字段名"

5 判断某列是否重复
public static bool CheckIfSame(UltraGrid ug, string colname)
  {
   for(int i = 0; i < ug.Rows.Count; i++)
   {
    for(int j = i+1; j < ug.Rows.Count; j++)
    {
     if(ug.Rows[i].Cells[colname].Text == ug.Rows[j].Cells[colname].Text && ug.Rows[i].Cells[colname].Text != "")
     {
      return true;
     }
    }
   }
   return false;
  }

6 Enter切换,在form_load事件里写
   this.ultraGrid1.KeyActionMappings.Add(new Infragistics.Win.UltraWinGrid.GridKeyActionMapping(System.Windows.Forms.Keys.Enter, Infragistics.Win.UltraWinGrid.UltraGridAction.NextCell, Infragistics.Win.UltraWinGrid.UltraGridState.IsCheckbox, Infragistics.Win.UltraWinGrid.UltraGridState.Cell, 0, 0));

7 选中一行
this.ultraGrid1.Rows[i].Activate();
      this.ultraGrid1.Rows[i].Selected = true;

    猜你喜欢
    发表评论评论公约
    喜欢该文的人也喜欢 更多