protected override object GetSelectedItem(object selectedItem, object contextInstance) { MB.Util.Model.CodeNameInfo colInfo = selectedItem as MB.Util.Model.CodeNameInfo; XtraStyleConditionInfo conditionInfo = contextInstance as XtraStyleConditionInfo; conditionInfo.ColumnName = colInfo.CODE; return(colInfo.NAME); }
/// <summary> /// 加载选择的列信息。 /// </summary> /// <param name="lstBox"></param> /// <param name="contextInstance"></param> protected override void AddDataToList(System.Windows.Forms.ListBox lstBox, object contextInstance) { if (contextInstance == null) { return; } XtraStyleConditionInfo conditionInfo = contextInstance as XtraStyleConditionInfo; DevExpress.XtraGrid.Views.Grid.GridView gridView = conditionInfo.Tag as DevExpress.XtraGrid.Views.Grid.GridView; lstBox.Items.Clear(); foreach (DevExpress.XtraGrid.Columns.GridColumn colInfo in gridView.Columns) { MB.Util.Model.CodeNameInfo codeName = new MB.Util.Model.CodeNameInfo(colInfo.FieldName, colInfo.Caption); lstBox.Items.Add(codeName); } }
/// <summary> /// 获取编辑框 /// </summary> /// <param name="instance">XtraStyleConditionInfo实例</param> /// <returns>返回编辑框实例</returns> protected override Form GetDialog(object instance) { XtraStyleConditionInfo conditionInfo = instance as XtraStyleConditionInfo; GridView gridView = conditionInfo.Tag as GridView; StyleFormatCondition condition = null; foreach (StyleFormatCondition item in gridView.FormatConditions) { if (item.Tag.ToString() == conditionInfo.Name) { condition = item; break; } } this._form = new ConditionExpressionEditorForm(condition, null); return(this._form); }
/// <summary> /// 条件样式值编辑器显示下拉框,把RepositoryItemLookUpEdit中的值显示出来 /// </summary> /// <param name="lstBox"></param> /// <param name="contextInstance"></param> protected override void AddDataToList(System.Windows.Forms.ListBox lstBox, object contextInstance) { XtraStyleConditionInfo conditionInfo = contextInstance as XtraStyleConditionInfo; GridView gridView = conditionInfo.Tag as GridView; if (gridView != null) { // 条件样式中的列名 if (!string.IsNullOrEmpty(conditionInfo.ColumnName)) { var column = gridView.Columns[conditionInfo.ColumnName]; lstBox.Items.Clear(); if (column != null) { if (column.ColumnEdit is RepositoryItemLookUpEdit) { var ddl = column.ColumnEdit as RepositoryItemLookUpEdit; if (ddl.DataSource is DataView) { var view = ddl.DataSource as DataView; foreach (DataRow row in view.Table.Rows) { CodeNameInfo codeName = new CodeNameInfo( row[ddl.ValueMember].ToString(), row[ddl.DisplayMember].ToString() + "-" + row[ddl.ValueMember].ToString()); lstBox.Items.Add(codeName); } } } } } } }