using System; using System.Collections.Generic; using System.Linq; using System.Text; using Infragistics.Win.UltraWinGrid; using System.Windows.Forms; using System.Data; using System.Collections; using Infragistics.Win.UltraWinEditors; namespace Pur.Balance { public class ValueListItem { public ValueListItem(string sID, string sName) { ID = sID; Name = sName; } public string ID { get; set; } public string Name { get; set; } // public override string ToString(); } class BalanceClassCommon { //激活输入当前值行数据 /// /// 激活输入当前值行数据 /// /// ultragrid /// 列名 /// 列值 public static string doActiveSelRow(UltraGrid ug, string strColumn, string strKey) { try { if (strKey != "") { foreach (UltraGridRow row in ug.Rows) { if (row.Cells[strColumn].Text.ToString() == strKey) { row.Activated = true; if (row.ChildBands != null) row.Expanded = true; } } } return ""; } catch (Exception ex) { return ex.ToString(); } } /// /// 设置grid单元格不可编辑 /// /// grid表格 /// 可编辑的列头名称数组 public static void setGridActivation(UltraGridBand band, params string[] strs) { foreach (UltraGridColumn column in band.Columns) { if (!strs.Contains(column.Key)) { column.CellActivation = Activation.ActivateOnly; } else { column.CellActivation = Activation.AllowEdit; } } } /// /// 绑定combobox /// /// 控件名 /// 数据源ds /// 值 /// 显示名 /// 筛选条件 public static void FilCombobox(UltraComboEditor cmbx, DataSet dset, string strVal, string strName, string filCondition) { if (dset.Tables.Count > 0 && dset.Tables[0].Columns.Count > 1) { DataView dvw = dset.Tables[0].DefaultView; dvw.RowFilter = filCondition; ArrayList aryTmp = new ArrayList(); for (int i = 0; i < dvw.Count; i++) { aryTmp.Add(new ValueListItem(dvw[i][strVal].ToString(), dvw[i][strName].ToString())); } cmbx.DisplayMember = "Name"; cmbx.ValueMember = "ID"; cmbx.DataSource = aryTmp; } } /// /// 绑定combobox /// /// 控件名 /// 数据源ds /// 值 /// 显示名 /// 筛选条件 public static void FilComboboxbyList(UltraComboEditor cmbx, ArrayList list) { cmbx.DisplayMember = "Name"; cmbx.ValueMember = "ID"; cmbx.DataSource = list; } } }