1 委托
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);
2 判断
e.Cell.Column.Key == "字段名"
3 判断某列是否重复
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;
}
4 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));
5 选中一行
this.ultraGrid1.Rows[i].Activate();
this.ultraGrid1.Rows[i].Selected = true;
6 新增一行,并将新行设为当前行
第一种:
Infragistics.Win.UltraWinGrid.UltraGridRow row = UltraGrid1.Rows.TemplateAddRow;
UltraGrid1.ActiveRow = row;
第二种
Infragistics.Win.UltraWinGrid.UltraGridRow row = UltraGrid1.Rows.Band.AddNew();
UltraGrid1.ActiveRow = row;
7 接受UltraGrid中编辑的值