public static void AddLookupEditColumn( this BandedGridView gridView, string fieldName, string caption, int width, object itemSource, string valueMember, string displayMember, bool isAllowEdit = true, List <ColumnInfo> columns = null, string nullText = "", bool showHearder = false, EventHandler editValueChanged = null) { RepositoryItemLookUpEdit itemCtrl = new RepositoryItemLookUpEdit { DataSource = itemSource, DisplayMember = displayMember, ValueMember = valueMember, NullText = nullText, ShowHeader = showHearder, TextEditStyle = TextEditStyles.Standard, AllowNullInput = DefaultBoolean.True }; if (editValueChanged != null) { itemCtrl.EditValueChanged += editValueChanged; } if (columns != null) { foreach (var col in columns) { var colInfo = new LookUpColumnInfo { FieldName = col.FieldName, Caption = col.Caption, Visible = true, }; if (col.Width > 0) { colInfo.Width = col.Width; } itemCtrl.Columns.Add(colInfo); } } else { itemCtrl.Columns.Add(new LookUpColumnInfo(displayMember)); } gridView.AddColumn(fieldName, caption, width, isAllowEdit, itemCtrl: itemCtrl); }
public static void AddSpinEditColumn( this BandedGridView gridView, string fieldName, string caption, int width, bool isAllowEdit = true, string formatString = "###,###,###,###,##0", SummaryItemType summaryType = SummaryItemType.None, string summaryFormat = "", string editFormat = "##############0") { RepositoryItemSpinEdit itemCtrl = new RepositoryItemSpinEdit(); itemCtrl.DisplayFormat.FormatString = formatString; itemCtrl.DisplayFormat.FormatType = FormatType.Custom; itemCtrl.EditFormat.FormatString = editFormat; itemCtrl.EditFormat.FormatType = FormatType.Custom; //Edit phải set # như vầy: ###,###,###,###,##0 itemCtrl.EditMask = editFormat; if (!isAllowEdit) { itemCtrl.Buttons[0].Visible = false; } GridColumnSummaryItem summaryItem = new GridColumnSummaryItem(); if (summaryType != SummaryItemType.None) { summaryFormat = string.IsNullOrEmpty(summaryFormat) ? "{0: " + formatString + "}" : summaryFormat; summaryItem = new GridColumnSummaryItem(summaryType, fieldName, summaryFormat); } gridView.AddColumn(fieldName, caption, width, isAllowEdit, itemCtrl: itemCtrl, summaryItem: summaryItem); }