private void SetupExtraGridFunctionality() { //Prepare grid to highlight inactive accounts/cost centres // Create a cell view for special conditions SourceGrid.Cells.Views.Cell strikeoutCell = new SourceGrid.Cells.Views.Cell(); strikeoutCell.Font = new System.Drawing.Font(grdDetails.Font, FontStyle.Strikeout); //strikeoutCell.ForeColor = Color.Crimson; // Create a condition, apply the view when true, and assign a delegate to handle it SourceGrid.Conditions.ConditionView conditionAccountCodeActive = new SourceGrid.Conditions.ConditionView(strikeoutCell); conditionAccountCodeActive.EvaluateFunction = delegate(SourceGrid.DataGridColumn column, int gridRow, object itemRow) { DataRowView row = (DataRowView)itemRow; string accountCode = row[ARecurringGiftBatchTable.ColumnBankAccountCodeId].ToString(); return(!AccountIsActive(accountCode)); }; SourceGrid.Conditions.ConditionView conditionCostCentreCodeActive = new SourceGrid.Conditions.ConditionView(strikeoutCell); conditionCostCentreCodeActive.EvaluateFunction = delegate(SourceGrid.DataGridColumn column, int gridRow, object itemRow) { DataRowView row = (DataRowView)itemRow; string costCentreCode = row[ARecurringGiftBatchTable.ColumnBankCostCentreId].ToString(); return(!CostCentreIsActive(costCentreCode)); }; //Add conditions to columns int indexOfCostCentreCodeDataColumn = 5; int indexOfAccountCodeDataColumn = 6; grdDetails.Columns[indexOfCostCentreCodeDataColumn].Conditions.Add(conditionCostCentreCodeActive); grdDetails.Columns[indexOfAccountCodeDataColumn].Conditions.Add(conditionAccountCodeActive); }
public static SourceGrid.Conditions.ICondition AlternateView( SourceGrid.Cells.Views.IView view, System.Drawing.Color alternateBackcolor, System.Drawing.Color alternateForecolor) { SourceGrid.Cells.Views.IView viewAlternate = (SourceGrid.Cells.Views.IView)view.Clone(); viewAlternate.BackColor = alternateBackcolor; viewAlternate.ForeColor = alternateForecolor; SourceGrid.Conditions.ConditionView condition = new SourceGrid.Conditions.ConditionView(viewAlternate); condition.EvaluateFunction = delegate(SourceGrid.DataGridColumn column, int gridRow, object itemRow) { return((gridRow & 1) == 1); }; return(condition); }
public static ICondition AlternateView( IView view, System.Drawing.Color alternateBackcolor, System.Drawing.Color alternateForecolor) { SourceGrid.Cells.Views.IView viewAlternate = (SourceGrid.Cells.Views.IView)view.Clone(); viewAlternate.BackColor = alternateBackcolor; viewAlternate.ForeColor = alternateForecolor; SourceGrid.Conditions.ConditionView condition = new SourceGrid.Conditions.ConditionView(viewAlternate); condition.EvaluateFunction = delegate(SourceGrid.DataGridColumn column, int gridRow, object itemRow) { return (gridRow & 1) == 1; }; return condition; }
private void SetupExtraGridFunctionality() { //Prepare grid to highlight inactive accounts/cost centres // Create a cell view for special conditions SourceGrid.Cells.Views.Cell strikeoutCell = new SourceGrid.Cells.Views.Cell(); strikeoutCell.Font = new System.Drawing.Font(grdDetails.Font, FontStyle.Strikeout); //strikeoutCell.ForeColor = Color.Crimson; // Create a condition, apply the view when true, and assign a delegate to handle it SourceGrid.Conditions.ConditionView conditionAccountCodeActive = new SourceGrid.Conditions.ConditionView(strikeoutCell); conditionAccountCodeActive.EvaluateFunction = delegate(SourceGrid.DataGridColumn column, int gridRow, object itemRow) { DataRowView row = (DataRowView)itemRow; string accountCode = row[AGiftBatchTable.ColumnBankAccountCodeId].ToString(); return !FAccountAndCostCentreLogicObject.AccountIsActive(accountCode); }; SourceGrid.Conditions.ConditionView conditionCostCentreCodeActive = new SourceGrid.Conditions.ConditionView(strikeoutCell); conditionCostCentreCodeActive.EvaluateFunction = delegate(SourceGrid.DataGridColumn column, int gridRow, object itemRow) { DataRowView row = (DataRowView)itemRow; string costCentreCode = row[AGiftBatchTable.ColumnBankCostCentreId].ToString(); return !FAccountAndCostCentreLogicObject.CostCentreIsActive(costCentreCode); }; //Add conditions to columns int indexOfCostCentreCodeDataColumn = 7; int indexOfAccountCodeDataColumn = 8; grdDetails.Columns[indexOfCostCentreCodeDataColumn].Conditions.Add(conditionCostCentreCodeActive); grdDetails.Columns[indexOfAccountCodeDataColumn].Conditions.Add(conditionAccountCodeActive); }
private void InitializeAccountDataGrid() { #region InitializeAccountDataGrid this.accountDataTable = new System.Data.DataTable(); this.accountDataTable.Columns.Add(Account_Column_Order, typeof(int)); this.accountDataTable.Columns.Add(Account_Column_AccountId, typeof(int)); this.accountDataTable.Columns.Add(Account_Column_TopMost, typeof(short)); this.accountDataTable.Columns.Add(Account_Column_Name, typeof(string)); this.accountDataTable.Columns.Add(Account_Column_LoginName, typeof(string)); this.accountDataTable.Columns.Add(Account_Column_Secret, typeof(SecretRank)); this.accountDataTable.Columns.Add(Account_Column_Email, typeof(string)); this.accountDataTable.Columns.Add(Account_Column_Mobile, typeof(string)); this.accountDataTable.Columns.Add(Account_Column_URL, typeof(string)); this.accountDataTable.Columns.Add(Account_Column_CreateTime, typeof(System.DateTime)); this.accountDataTable.Columns.Add(Account_Column_UpdateTime, typeof(System.DateTime)); this.dataGridAccount.BorderStyle = BorderStyle.Fixed3D; this.dataGridAccount.BackColor = System.Drawing.SystemColors.AppWorkspace; this.dataGridAccount.Font = ApplicationDefines.DefaultDataGridCellFont; this.dataGridAccount.Rows.RowHeight = 30; this.dataGridAccount.Rows.SetHeight(0, 30); this.dataGridAccount.SelectionMode = SourceGrid.GridSelectionMode.Cell; this.dataGridAccount.Selection.EnableMultiSelection = true; this.dataGridAccount.ClipboardMode = SourceGrid.ClipboardMode.All; var tmpGridSelection = this.dataGridAccount.Selection as SourceGrid.Selection.SelectionBase; if (tmpGridSelection != null) { tmpGridSelection.Border = tmpGridSelection.Border.SetColor(System.Drawing.Color.Blue); tmpGridSelection.BackColor = System.Drawing.Color.FromArgb(60, tmpGridSelection.BackColor); } SourceGrid.DataGridColumn tmpGridColumn; tmpGridColumn = this.dataGridAccount.Columns.Add(Account_Column_Order, SafePassResource.DataGridAccountColumnOrderNo, typeof(int)); tmpGridColumn = this.dataGridAccount.Columns.Add(Account_Column_AccountId, SafePassResource.DataGridAccountColumnAccountGuid, typeof(string)); tmpGridColumn = this.dataGridAccount.Columns.Add(Account_Column_TopMost, SafePassResource.DataGridAccountColumnTopMost, typeof(short)); tmpGridColumn = this.dataGridAccount.Columns.Add(Account_Column_Name, SafePassResource.DataGridAccountColumnName, typeof(string)); tmpGridColumn = this.dataGridAccount.Columns.Add(Account_Column_Secret, SafePassResource.DataGridAccountColumnSecret, typeof(SecretRank)); tmpGridColumn = this.dataGridAccount.Columns.Add(Account_Column_LoginName, SafePassResource.DataGridAccountColumnLoginName, typeof(string)); tmpGridColumn = this.dataGridAccount.Columns.Add(Account_Column_Mobile, SafePassResource.DataGridAccountColumnMobile, typeof(string)); tmpGridColumn = this.dataGridAccount.Columns.Add(Account_Column_Email, SafePassResource.DataGridAccountColumnEmail, typeof(string)); tmpGridColumn = this.dataGridAccount.Columns.Add(Account_Column_CreateTime, SafePassResource.DataGridAccountColumnCreateTime, typeof(System.DateTime)); tmpGridColumn = this.dataGridAccount.Columns.Add(Account_Column_UpdateTime, SafePassResource.DataGridAccountColumnUpdateTime, typeof(System.DateTime)); tmpGridColumn = this.dataGridAccount.Columns.Add(Account_Column_URL, SafePassResource.DataGridAccountColumnURL, typeof(string)); var tmpDateTimeFormat = ApplicationDefines.DateTimeFormat; var dateTimeParseFormats = new string[] { tmpDateTimeFormat }; var tmpDateTimeStyles = System.Globalization.DateTimeStyles.AllowInnerWhite | System.Globalization.DateTimeStyles.AllowLeadingWhite | System.Globalization.DateTimeStyles.AllowTrailingWhite | System.Globalization.DateTimeStyles.AllowWhiteSpaces; var tmpDateTimeEditor = new SourceGrid.Cells.Editors.TextBoxUITypeEditor(typeof(System.DateTime)); tmpDateTimeEditor.TypeConverter = new DevAge.ComponentModel.Converter.DateTimeTypeConverter(tmpDateTimeFormat, dateTimeParseFormats, tmpDateTimeStyles); var tmpDataSource = new DevAge.ComponentModel.BoundDataView(this.accountDataTable.DefaultView); tmpDataSource.AllowNew = false; tmpDataSource.AllowSort = true; this.dataGridAccount.DataSource = tmpDataSource; var tmpGridColor = System.Drawing.SystemColors.ActiveBorder; var tmpGridBorder = new DevAge.Drawing.RectangleBorder(new DevAge.Drawing.BorderLine(tmpGridColor, 0), new DevAge.Drawing.BorderLine(tmpGridColor)); var tmpGridLinkCellView = new SourceGrid.Cells.Views.Link(); tmpGridLinkCellView.Font = ApplicationDefines.DefaultDataGridCellFont; var tmpAlignCenterCellView = new SourceGrid.Cells.Views.Cell(); tmpAlignCenterCellView.TextAlignment = DevAge.Drawing.ContentAlignment.MiddleCenter; tmpAlignCenterCellView.Font = ApplicationDefines.DefaultDataGridCellFont; var tmpLoginNameCellView = new SourceGrid.Cells.Views.Cell(); tmpLoginNameCellView.Font = new System.Drawing.Font("Consolas", 10, System.Drawing.FontStyle.Regular); this.SecretCellRank0 = new SourceGrid.Cells.Views.Cell(); this.SecretCellRank0.ForeColor = System.Drawing.Color.White; this.SecretCellRank0.BackColor = Program.Config.Application.Security.SecretRank.Rank0BackColor; this.SecretCellRank0.TextAlignment = DevAge.Drawing.ContentAlignment.MiddleCenter; this.SecretCellRank0.Font = ApplicationDefines.DefaultDataGridCellFont; this.SecretCellRank1 = new SourceGrid.Cells.Views.Cell(); this.SecretCellRank1.ForeColor = System.Drawing.Color.White; this.SecretCellRank1.BackColor = Program.Config.Application.Security.SecretRank.Rank1BackColor; this.SecretCellRank1.TextAlignment = DevAge.Drawing.ContentAlignment.MiddleCenter; this.SecretCellRank1.Font = ApplicationDefines.DefaultDataGridCellFont; this.SecretCellRank2 = new SourceGrid.Cells.Views.Cell(); this.SecretCellRank2.ForeColor = System.Drawing.Color.White; this.SecretCellRank2.BackColor = Program.Config.Application.Security.SecretRank.Rank2BackColor; this.SecretCellRank2.TextAlignment = DevAge.Drawing.ContentAlignment.MiddleCenter; this.SecretCellRank2.Font = ApplicationDefines.DefaultDataGridCellFont; this.SecretCellRank3 = new SourceGrid.Cells.Views.Cell(); this.SecretCellRank3.ForeColor = System.Drawing.Color.White; this.SecretCellRank3.BackColor = Program.Config.Application.Security.SecretRank.Rank3BackColor; this.SecretCellRank3.TextAlignment = DevAge.Drawing.ContentAlignment.MiddleCenter; this.SecretCellRank3.Font = ApplicationDefines.DefaultDataGridCellFont; var tmpTopMostModel = new SourceGrid.Cells.Views.Cell(); tmpTopMostModel.ImageAlignment = DevAge.Drawing.ContentAlignment.MiddleCenter; this.GridCellTopMost = new SourceGrid.Cells.Cell(); this.GridCellTopMost.View = new SourceGrid.Cells.Views.Cell(tmpTopMostModel); this.GridCellTopMost.Image = HuiruiSoft.Safe.Properties.Resources.TopMost; this.GridCellTopNone = new SourceGrid.Cells.Cell(); this.GridCellTopNone.View = new SourceGrid.Cells.Views.Cell(tmpTopMostModel); this.GridCellTopNone.Image = HuiruiSoft.Safe.Properties.Resources.TopNone; var tmpConditionTopMost = new SourceGrid.Conditions.ConditionCell(this.GridCellTopMost); tmpConditionTopMost.EvaluateFunction = delegate(SourceGrid.DataGridColumn column, int gridRow, object itemRow) { var tmpDataRow = (System.Data.DataRowView)itemRow; return(tmpDataRow[Account_Column_TopMost] is short && (short)tmpDataRow[Account_Column_TopMost] > 0); }; var tmpConditionTopNone = new SourceGrid.Conditions.ConditionCell(this.GridCellTopNone); tmpConditionTopNone.EvaluateFunction = delegate(SourceGrid.DataGridColumn column, int gridRow, object itemRow) { var tmpDataRow = (System.Data.DataRowView)itemRow; return(tmpDataRow[Account_Column_TopMost] is short && (short)tmpDataRow[Account_Column_TopMost] <= 0); }; var tmpConditionRank0 = new SourceGrid.Conditions.ConditionView(this.SecretCellRank0); tmpConditionRank0.EvaluateFunction = delegate(SourceGrid.DataGridColumn column, int gridRow, object itemRow) { var tmpDataRow = (System.Data.DataRowView)itemRow; return(tmpDataRow[Account_Column_Secret] is ushort && (ushort)tmpDataRow[Account_Column_Secret] == (ushort)SecretRank.¹«¿ª); }; var tmpConditionRank1 = new SourceGrid.Conditions.ConditionView(this.SecretCellRank1); tmpConditionRank1.EvaluateFunction = delegate(SourceGrid.DataGridColumn column, int gridRow, object itemRow) { var tmpDataRow = (System.Data.DataRowView)itemRow; return(tmpDataRow[Account_Column_Secret] is ushort && (ushort)tmpDataRow[Account_Column_Secret] == (ushort)SecretRank.ÃØÃÜ); }; var tmpConditionRank2 = new SourceGrid.Conditions.ConditionView(this.SecretCellRank2); tmpConditionRank2.EvaluateFunction = delegate(SourceGrid.DataGridColumn column, int gridRow, object itemRow) { var tmpDataRow = (System.Data.DataRowView)itemRow; return(tmpDataRow[Account_Column_Secret] is ushort && (ushort)tmpDataRow[Account_Column_Secret] == (ushort)SecretRank.»úÃÜ); }; var tmpConditionRank3 = new SourceGrid.Conditions.ConditionView(this.SecretCellRank3); tmpConditionRank3.EvaluateFunction = delegate(SourceGrid.DataGridColumn column, int gridRow, object itemRow) { var tmpDataRow = (System.Data.DataRowView)itemRow; return(tmpDataRow[Account_Column_Secret] is ushort && (ushort)tmpDataRow[Account_Column_Secret] == (ushort)SecretRank.¾øÃÜ); }; for (int index = 0; index < this.dataGridAccount.Columns.Count; index++) { var tmpCurrentColumn = this.dataGridAccount.Columns[index]; tmpCurrentColumn.HeaderCell.View.Border = tmpGridBorder; tmpCurrentColumn.HeaderCell.View.TextAlignment = DevAge.Drawing.ContentAlignment.MiddleCenter; if (tmpCurrentColumn.DataCell.Editor != null) { tmpCurrentColumn.DataCell.Editor.EnableEdit = false; } switch (tmpCurrentColumn.PropertyName) { case Account_Column_AccountId: case Account_Column_CreateTime: tmpCurrentColumn.Width = 150; tmpCurrentColumn.Visible = false; break; case Account_Column_TopMost: tmpCurrentColumn.Width = 50; tmpCurrentColumn.Conditions.Add(tmpConditionTopNone); tmpCurrentColumn.Conditions.Add(tmpConditionTopMost); break; case Account_Column_Order: tmpCurrentColumn.Width = 50; tmpCurrentColumn.DataCell.View = tmpAlignCenterCellView; break; case Account_Column_Name: tmpCurrentColumn.Width = 175; break; case Account_Column_Secret: tmpCurrentColumn.Width = 80; tmpCurrentColumn.Conditions.Add(tmpConditionRank0); tmpCurrentColumn.Conditions.Add(tmpConditionRank1); tmpCurrentColumn.Conditions.Add(tmpConditionRank2); tmpCurrentColumn.Conditions.Add(tmpConditionRank3); break; case Account_Column_LoginName: tmpCurrentColumn.Width = 200; tmpCurrentColumn.DataCell.View = tmpLoginNameCellView; break; case Account_Column_Mobile: tmpCurrentColumn.Width = 120; tmpCurrentColumn.DataCell.View = tmpAlignCenterCellView; break; case Account_Column_Email: tmpCurrentColumn.Width = 200; break; case Account_Column_URL: tmpCurrentColumn.Width = 270; tmpCurrentColumn.DataCell.View = tmpGridLinkCellView; tmpCurrentColumn.DataCell.AddController(new LinkClickController()); break; case Account_Column_UpdateTime: tmpCurrentColumn.Width = 156; tmpCurrentColumn.DataCell.Editor = tmpDateTimeEditor; tmpCurrentColumn.DataCell.Editor.EnableEdit = false; tmpCurrentColumn.DataCell.View = tmpAlignCenterCellView; break; } } #endregion InitializeAccountDataGrid }
private void SetupAnalysisAttributeGrid(TSgrdDataGridPaged AGrid, ref SourceGrid.Cells.Editors.ComboBox AGridCombo) { AGrid.DataSource = null; GLBatchTDS DS = null; SourceGrid.Cells.Editors.ComboBox ATempCombo = null; if (AGrid.Name == grdFromAnalAttributes.Name) { FTempFromDS = (GLBatchTDS)FMainDS.Clone(); DS = FTempFromDS; } else { DS = FMainDS; } if (AGrid.Columns.Count == 0) { ATempCombo = new SourceGrid.Cells.Editors.ComboBox(typeof(string)); ATempCombo.EnableEdit = true; ATempCombo.EditableMode = EditableMode.Focus; AGrid.Columns.Clear(); AGrid.AddTextColumn(Catalog.GetString("Type"), FMainDS.ATransAnalAttrib.ColumnAnalysisTypeCode, 99); AGrid.AddTextColumn(Catalog.GetString("Value"), DS.ATransAnalAttrib.Columns[ATransAnalAttribTable.GetAnalysisAttributeValueDBName()], 150, ATempCombo); } FAnalysisAttributesLogic.SetTransAnalAttributeDefaultView(DS, true); DS.ATransAnalAttrib.DefaultView.AllowNew = false; AGrid.DataSource = new DevAge.ComponentModel.BoundDataView(DS.ATransAnalAttrib.DefaultView); AGrid.SetHeaderTooltip(0, Catalog.GetString("Type")); AGrid.SetHeaderTooltip(1, Catalog.GetString("Value")); AGrid.Selection.SelectionChanged += AnalysisAttributesGrid_RowSelected; //Prepare Analysis attributes grid to highlight inactive analysis codes // Create a cell view for special conditions SourceGrid.Cells.Views.Cell strikeoutCell2 = new SourceGrid.Cells.Views.Cell(); strikeoutCell2.Font = new System.Drawing.Font(AGrid.Font, FontStyle.Strikeout); // Create a condition, apply the view when true, and assign a delegate to handle it SourceGrid.Conditions.ConditionView conditionAnalysisCodeActive = new SourceGrid.Conditions.ConditionView(strikeoutCell2); conditionAnalysisCodeActive.EvaluateFunction = delegate(SourceGrid.DataGridColumn column2, int gridRow2, object itemRow2) { DataRowView row2 = (DataRowView)itemRow2; string analysisCode = row2[ATransAnalAttribTable.ColumnAnalysisTypeCodeId].ToString(); if (AGrid.Name == grdFromAnalAttributes.Name) { return !FAnalysisAttributesLogic.AnalysisCodeIsActive( FPreviouslySelectedAccountsRow[AGeneralLedgerMasterTable.GetAccountCodeDBName()].ToString(), FCacheDS.AAnalysisAttribute, analysisCode); } return !FAnalysisAttributesLogic.AnalysisCodeIsActive( cmbDetailAccountCode.GetSelectedString(), FCacheDS.AAnalysisAttribute, analysisCode); }; // Create a condition, apply the view when true, and assign a delegate to handle it SourceGrid.Conditions.ConditionView conditionAnalysisAttributeValueActive = new SourceGrid.Conditions.ConditionView(strikeoutCell2); conditionAnalysisAttributeValueActive.EvaluateFunction = delegate(SourceGrid.DataGridColumn column2, int gridRow2, object itemRow2) { if (itemRow2 != null) { DataRowView row2 = (DataRowView)itemRow2; string analysisCode = row2[ATransAnalAttribTable.ColumnAnalysisTypeCodeId].ToString(); string analysisAttributeValue = row2[ATransAnalAttribTable.ColumnAnalysisAttributeValueId].ToString(); return !TAnalysisAttributes.AnalysisAttributeValueIsActive(ref ATempCombo, FCacheDS.AFreeformAnalysis, analysisCode, analysisAttributeValue); } else { return false; } }; //Add conditions to columns int indexOfAnalysisCodeColumn = 0; int indexOfAnalysisAttributeValueColumn = 1; AGrid.Columns[indexOfAnalysisCodeColumn].Conditions.Add(conditionAnalysisCodeActive); AGrid.Columns[indexOfAnalysisAttributeValueColumn].Conditions.Add(conditionAnalysisAttributeValueActive); AGridCombo = ATempCombo; }
private void SetupExtraGridFunctionality() { DataTable CostCentreListTable = TDataCache.TMFinance.GetCacheableFinanceTable(TCacheableFinanceTablesEnum.CostCentreList, FLedgerNumber); ACostCentreTable tmpCostCentreTable = new ACostCentreTable(); FMainDS.Tables.Add(tmpCostCentreTable); DataUtilities.ChangeDataTableToTypedDataTable(ref CostCentreListTable, FMainDS.Tables[tmpCostCentreTable.TableName].GetType(), ""); FMainDS.RemoveTable(tmpCostCentreTable.TableName); if ((CostCentreListTable == null) || (CostCentreListTable.Rows.Count == 0)) { FCostCentreList = null; } else { FCostCentreList = (ACostCentreTable)CostCentreListTable; } DataTable AccountListTable = TDataCache.TMFinance.GetCacheableFinanceTable(TCacheableFinanceTablesEnum.AccountList, FLedgerNumber); AAccountTable tmpAccountTable = new AAccountTable(); FMainDS.Tables.Add(tmpAccountTable); DataUtilities.ChangeDataTableToTypedDataTable(ref AccountListTable, FMainDS.Tables[tmpAccountTable.TableName].GetType(), ""); FMainDS.RemoveTable(tmpAccountTable.TableName); if ((AccountListTable == null) || (AccountListTable.Rows.Count == 0)) { FAccountList = null; } else { FAccountList = (AAccountTable)AccountListTable; } //Prepare grid to highlight inactive accounts/cost centres // Create a cell view for special conditions SourceGrid.Cells.Views.Cell strikeoutCell = new SourceGrid.Cells.Views.Cell(); strikeoutCell.Font = new System.Drawing.Font(grdDetails.Font, FontStyle.Strikeout); //strikeoutCell.ForeColor = Color.Crimson; // Create a condition, apply the view when true, and assign a delegate to handle it SourceGrid.Conditions.ConditionView conditionAccountCodeActive = new SourceGrid.Conditions.ConditionView(strikeoutCell); conditionAccountCodeActive.EvaluateFunction = delegate(SourceGrid.DataGridColumn column, int gridRow, object itemRow) { DataRowView row = (DataRowView)itemRow; string accountCode = row[ATransactionTable.ColumnAccountCodeId].ToString(); return !AccountIsActive(accountCode); }; SourceGrid.Conditions.ConditionView conditionCostCentreCodeActive = new SourceGrid.Conditions.ConditionView(strikeoutCell); conditionCostCentreCodeActive.EvaluateFunction = delegate(SourceGrid.DataGridColumn column, int gridRow, object itemRow) { DataRowView row = (DataRowView)itemRow; string costCentreCode = row[ATransactionTable.ColumnCostCentreCodeId].ToString(); return !CostCentreIsActive(costCentreCode); }; //Add conditions to columns int indexOfCostCentreCodeDataColumn = 2; int indexOfAccountCodeDataColumn = 3; grdDetails.Columns[indexOfCostCentreCodeDataColumn].Conditions.Add(conditionCostCentreCodeActive); grdDetails.Columns[indexOfAccountCodeDataColumn].Conditions.Add(conditionAccountCodeActive); //Prepare Analysis attributes grid to highlight inactive analysis codes // Create a cell view for special conditions SourceGrid.Cells.Views.Cell strikeoutCell2 = new SourceGrid.Cells.Views.Cell(); strikeoutCell2.Font = new System.Drawing.Font(grdAnalAttributes.Font, FontStyle.Strikeout); //strikeoutCell.ForeColor = Color.Crimson; // Create a condition, apply the view when true, and assign a delegate to handle it SourceGrid.Conditions.ConditionView conditionAnalysisCodeActive = new SourceGrid.Conditions.ConditionView(strikeoutCell2); conditionAnalysisCodeActive.EvaluateFunction = delegate(SourceGrid.DataGridColumn column2, int gridRow2, object itemRow2) { DataRowView row2 = (DataRowView)itemRow2; string analysisCode = row2[ATransAnalAttribTable.ColumnAnalysisTypeCodeId].ToString(); return !FAnalysisAttributesLogic.AnalysisCodeIsActive( cmbDetailAccountCode.GetSelectedString(), FCacheDS.AAnalysisAttribute, analysisCode); }; // Create a condition, apply the view when true, and assign a delegate to handle it SourceGrid.Conditions.ConditionView conditionAnalysisAttributeValueActive = new SourceGrid.Conditions.ConditionView(strikeoutCell2); conditionAnalysisAttributeValueActive.EvaluateFunction = delegate(SourceGrid.DataGridColumn column2, int gridRow2, object itemRow2) { if (itemRow2 != null) { DataRowView row2 = (DataRowView)itemRow2; string analysisCode = row2[ATransAnalAttribTable.ColumnAnalysisTypeCodeId].ToString(); string analysisAttributeValue = row2[ATransAnalAttribTable.ColumnAnalysisAttributeValueId].ToString(); return !TAnalysisAttributes.AnalysisAttributeValueIsActive(ref FcmbAnalAttribValues, FCacheDS.AFreeformAnalysis, analysisCode, analysisAttributeValue); } else { return false; } }; //Add conditions to columns int indexOfAnalysisCodeColumn = 0; int indexOfAnalysisAttributeValueColumn = 1; grdAnalAttributes.Columns[indexOfAnalysisCodeColumn].Conditions.Add(conditionAnalysisCodeActive); grdAnalAttributes.Columns[indexOfAnalysisAttributeValueColumn].Conditions.Add(conditionAnalysisAttributeValueActive); }
private void SetupGrid() { // manually add a forth column which displays the fields partner short name DataColumn FieldName = new DataColumn("FieldName", Type.GetType("System.String")); FMainDS.PPartnerGiftDestination.Columns.Add(FieldName); grdDetails.Columns.Clear(); grdDetails.AddDateColumn("Date Effective From", FMainDS.PPartnerGiftDestination.ColumnDateEffective); grdDetails.AddDateColumn("Date of Expiry", FMainDS.PPartnerGiftDestination.ColumnDateExpires); grdDetails.AddPartnerKeyColumn("Field Key", FMainDS.PPartnerGiftDestination.ColumnFieldKey); grdDetails.AddPartnerKeyColumn("Field Name", FieldName); foreach (DataRow Row in FMainDS.PPartnerGiftDestination.Rows) { string PartnerShortName; TPartnerClass PartnerClass; TRemote.MPartner.Partner.ServerLookups.WebConnectors.GetPartnerShortName( Convert.ToInt64(Row[PPartnerGiftDestinationTable.ColumnFieldKeyId]), out PartnerShortName, out PartnerClass); Row["FieldName"] = PartnerShortName; } // create a new column so we can to sort the table with null DateExpires values at the top DataColumn NewColumn = new DataColumn("Order", Type.GetType("System.DateTime")); FMainDS.PPartnerGiftDestination.Columns.Add(NewColumn); foreach (DataRow Row in FMainDS.PPartnerGiftDestination.Rows) { if (Row["p_date_expires_d"] == DBNull.Value) { Row["Order"] = DateTime.MaxValue; } else { Row["Order"] = Row["p_date_expires_d"]; } } DataView myDataView = FMainDS.PPartnerGiftDestination.DefaultView; myDataView.Sort = "Order DESC, p_date_effective_d DESC"; myDataView.AllowNew = false; grdDetails.DataSource = new DevAge.ComponentModel.BoundDataView(myDataView); grdDetails.Columns.AutoSize(false); //Prepare grid to highlight inactive Gift Destinations SourceGrid.Cells.Views.Cell strikeoutCell = new SourceGrid.Cells.Views.Cell(); strikeoutCell.Font = new System.Drawing.Font(grdDetails.Font, FontStyle.Strikeout); // Create a condition, apply the view when true, and assign a delegate to handle it SourceGrid.Conditions.ConditionView condition = new SourceGrid.Conditions.ConditionView(strikeoutCell); condition.EvaluateFunction = delegate(SourceGrid.DataGridColumn column, int gridRow, object itemRow) { DataRowView row = (DataRowView)itemRow; if (row[PPartnerGiftDestinationTable.ColumnDateEffectiveId].ToString() == row[PPartnerGiftDestinationTable.ColumnDateExpiresId].ToString()) { return true; } return false; }; // add condtion to grid columns grdDetails.Columns[0].Conditions.Add(condition); grdDetails.Columns[1].Conditions.Add(condition); grdDetails.Columns[2].Conditions.Add(condition); grdDetails.Columns[3].Conditions.Add(condition); }
private void CreateColumns(DevAge.ComponentModel.IBoundList boundList) { //Create the editors SourceGrid.Cells.Editors.TextBoxNumeric numericEditor = new SourceGrid.Cells.Editors.TextBoxNumeric(typeof(decimal)); numericEditor.TypeConverter = new DevAge.ComponentModel.Converter.NumberTypeConverter(typeof(decimal), "N"); numericEditor.AllowNull = true; //the database value can be null (System.DbNull) SourceGrid.Cells.Editors.ComboBox externalIdEditor = new SourceGrid.Cells.Editors.ComboBox(typeof(int)); externalIdEditor.StandardValues = new int[]{1, 2, 3, 4}; externalIdEditor.StandardValuesExclusive = true; externalIdEditor.Control.FormattingEnabled = true; DevAge.ComponentModel.Validator.ValueMapping mapping = new DevAge.ComponentModel.Validator.ValueMapping(); mapping.ValueList = new int[]{1, 2, 3, 4}; mapping.DisplayStringList = new string[] { "Reference 1", "Reference 2", "Reference 3", "Reference 4" }; mapping.BindValidator(externalIdEditor); //Create the views SourceGrid.Cells.Views.Cell viewSelected = new SourceGrid.Cells.Views.Cell(); viewSelected.Font = new Font(dataGrid.Font, FontStyle.Bold); viewSelected.ForeColor = Color.DarkGreen; //Create selected conditions SourceGrid.Conditions.ConditionView selectedConditionBold = new SourceGrid.Conditions.ConditionView(viewSelected); selectedConditionBold.EvaluateFunction = delegate(SourceGrid.DataGridColumn column, int gridRow, object itemRow) { DataRowView row = (DataRowView)itemRow; return row["Selected"] is bool && (bool)row["Selected"] == true; }; SourceGrid.Conditions.ConditionCell selectedConditionStar = new SourceGrid.Conditions.ConditionCell(new SourceGrid.Cells.Virtual.CellVirtual()); selectedConditionStar.Cell.Model.AddModel(new SourceGrid.Cells.Models.Image(Properties.Resources.Star.ToBitmap())); selectedConditionStar.EvaluateFunction = delegate(SourceGrid.DataGridColumn column, int gridRow, object itemRow) { DataRowView row = (DataRowView)itemRow; return row["Selected"] is bool && (bool)row["Selected"] == true; }; //Create columns SourceGrid.DataGridColumn gridColumn; gridColumn = dataGrid.Columns.Add("Selected", "Selected", typeof(bool)); gridColumn = dataGrid.Columns.Add("Country", "Country", typeof(string)); gridColumn.DataCell.Model.AddModel(new BoundImage("Uniform")); gridColumn.Conditions.Add(selectedConditionBold); gridColumn = dataGrid.Columns.Add("Uniform", "Uniform", new SourceGrid.Cells.DataGrid.Image()); gridColumn.Conditions.Add(selectedConditionBold); gridColumn = dataGrid.Columns.Add("Population", "Population", numericEditor); gridColumn.Conditions.Add(selectedConditionBold); gridColumn = dataGrid.Columns.Add("Surface", "Surface", numericEditor); gridColumn.Conditions.Add(selectedConditionBold); gridColumn = dataGrid.Columns.Add("ExternalID", "ExternalID", externalIdEditor); gridColumn.Conditions.Add(selectedConditionBold); gridColumn = dataGrid.Columns.Add("Star", "Star", new SourceGrid.Cells.Virtual.CellVirtual()); gridColumn.DataCell.Model.AddModel(new SourceGrid.Cells.Models.Image(Properties.Resources.StarOff)); gridColumn.Conditions.Add(selectedConditionStar); foreach (SourceGrid.DataGridColumn col in dataGrid.Columns) { col.DataCell.AddController(SourceGrid.Cells.Controllers.ToolTipText.Default); col.DataCell.Model.AddModel(MyToolTipModel.Default); } }
private void CreateColumns(DevAge.ComponentModel.IBoundList boundList) { //Create the editors SourceGrid.Cells.Editors.TextBoxNumeric numericEditor = new SourceGrid.Cells.Editors.TextBoxNumeric(typeof(decimal)); numericEditor.TypeConverter = new DevAge.ComponentModel.Converter.NumberTypeConverter(typeof(decimal), "N"); numericEditor.AllowNull = true; //the database value can be null (System.DbNull) SourceGrid.Cells.Editors.ComboBox externalIdEditor = new SourceGrid.Cells.Editors.ComboBox(typeof(int)); externalIdEditor.StandardValues = new int[] { 1, 2, 3, 4 }; externalIdEditor.StandardValuesExclusive = true; externalIdEditor.Control.FormattingEnabled = true; DevAge.ComponentModel.Validator.ValueMapping mapping = new DevAge.ComponentModel.Validator.ValueMapping(); mapping.ValueList = new int[] { 1, 2, 3, 4 }; mapping.DisplayStringList = new string[] { "Reference 1", "Reference 2", "Reference 3", "Reference 4" }; mapping.BindValidator(externalIdEditor); //Create the views SourceGrid.Cells.Views.Cell viewSelected = new SourceGrid.Cells.Views.Cell(); viewSelected.Font = new Font(dataGrid.Font, FontStyle.Bold); viewSelected.ForeColor = Color.DarkGreen; //Create selected conditions SourceGrid.Conditions.ConditionView selectedConditionBold = new SourceGrid.Conditions.ConditionView(viewSelected); selectedConditionBold.EvaluateFunction = delegate(SourceGrid.DataGridColumn column, int gridRow, object itemRow) { DataRowView row = (DataRowView)itemRow; return(row["Selected"] is bool && (bool)row["Selected"] == true); }; SourceGrid.Conditions.ConditionCell selectedConditionStar = new SourceGrid.Conditions.ConditionCell(new SourceGrid.Cells.Virtual.CellVirtual()); selectedConditionStar.Cell.Model.AddModel(new SourceGrid.Cells.Models.Image(Properties.Resources.Star.ToBitmap())); selectedConditionStar.EvaluateFunction = delegate(SourceGrid.DataGridColumn column, int gridRow, object itemRow) { DataRowView row = (DataRowView)itemRow; return(row["Selected"] is bool && (bool)row["Selected"] == true); }; //Create columns SourceGrid.DataGridColumn gridColumn; gridColumn = dataGrid.Columns.Add("Selected", "Selected", typeof(bool)); gridColumn = dataGrid.Columns.Add("Country", "Country", typeof(string)); gridColumn.DataCell.Model.AddModel(new BoundImage("Uniform")); gridColumn.Conditions.Add(selectedConditionBold); gridColumn = dataGrid.Columns.Add("Uniform", "Uniform", new SourceGrid.Cells.DataGrid.Image()); gridColumn.Conditions.Add(selectedConditionBold); gridColumn = dataGrid.Columns.Add("Population", "Population", numericEditor); gridColumn.Conditions.Add(selectedConditionBold); gridColumn = dataGrid.Columns.Add("Surface", "Surface", numericEditor); gridColumn.Conditions.Add(selectedConditionBold); gridColumn = dataGrid.Columns.Add("ExternalID", "ExternalID", externalIdEditor); gridColumn.Conditions.Add(selectedConditionBold); gridColumn = dataGrid.Columns.Add("Star", "Star", new SourceGrid.Cells.Virtual.CellVirtual()); gridColumn.DataCell.Model.AddModel(new SourceGrid.Cells.Models.Image(Properties.Resources.StarOff)); gridColumn.Conditions.Add(selectedConditionStar); foreach (SourceGrid.DataGridColumn col in dataGrid.Columns) { col.DataCell.AddController(SourceGrid.Cells.Controllers.ToolTipText.Default); col.DataCell.Model.AddModel(MyToolTipModel.Default); } }
private void SetupExtraGridFunctionality() { //Populate CostCentreList variable DataTable costCentreList = TDataCache.TMFinance.GetCacheableFinanceTable(TCacheableFinanceTablesEnum.CostCentreList, FLedgerNumber); ACostCentreTable tmpCostCentreTable = new ACostCentreTable(); FMainDS.Tables.Add(tmpCostCentreTable); DataUtilities.ChangeDataTableToTypedDataTable(ref costCentreList, FMainDS.Tables[tmpCostCentreTable.TableName].GetType(), ""); FMainDS.RemoveTable(tmpCostCentreTable.TableName); FCostCentreTable = (ACostCentreTable)costCentreList; //Populate AccountList variable DataTable accountList = TDataCache.TMFinance.GetCacheableFinanceTable(TCacheableFinanceTablesEnum.AccountList, FLedgerNumber); AAccountTable tmpAccountTable = new AAccountTable(); FMainDS.Tables.Add(tmpAccountTable); DataUtilities.ChangeDataTableToTypedDataTable(ref accountList, FMainDS.Tables[tmpAccountTable.TableName].GetType(), ""); FMainDS.RemoveTable(tmpAccountTable.TableName); FAccountTable = (AAccountTable)accountList; //Prepare grid to highlight inactive accounts/cost centres // Create a cell view for special conditions SourceGrid.Cells.Views.Cell strikeoutCell = new SourceGrid.Cells.Views.Cell(); strikeoutCell.Font = new System.Drawing.Font(grdDetails.Font, FontStyle.Strikeout); //strikeoutCell.ForeColor = Color.Crimson; // Create a condition, apply the view when true, and assign a delegate to handle it SourceGrid.Conditions.ConditionView conditionAccountCodeActive = new SourceGrid.Conditions.ConditionView(strikeoutCell); conditionAccountCodeActive.EvaluateFunction = delegate(SourceGrid.DataGridColumn column, int gridRow, object itemRow) { DataRowView row = (DataRowView)itemRow; string accountCode = row[ABudgetTable.ColumnAccountCodeId].ToString(); return !AccountIsActive(accountCode); }; SourceGrid.Conditions.ConditionView conditionCostCentreCodeActive = new SourceGrid.Conditions.ConditionView(strikeoutCell); conditionCostCentreCodeActive.EvaluateFunction = delegate(SourceGrid.DataGridColumn column, int gridRow, object itemRow) { DataRowView row = (DataRowView)itemRow; string costCentreCode = row[ABudgetTable.ColumnCostCentreCodeId].ToString(); return !CostCentreIsActive(costCentreCode); }; //Add conditions to columns int indexOfCostCentreCodeDataColumn = 0; int indexOfAccountCodeDataColumn = 1; grdDetails.Columns[indexOfCostCentreCodeDataColumn].Conditions.Add(conditionCostCentreCodeActive); grdDetails.Columns[indexOfAccountCodeDataColumn].Conditions.Add(conditionAccountCodeActive); }
private void SetupAnalysisAttributeGrid(TSgrdDataGridPaged AGrid, ref SourceGrid.Cells.Editors.ComboBox AGridCombo) { AGrid.DataSource = null; GLBatchTDS DS = null; TCmbAutoPopulated AccountCombo = null; SourceGrid.Cells.Editors.ComboBox ATempCombo = null; if (AGrid.Name == grdFromAnalAttributes.Name) { FTempFromDS = (GLBatchTDS)FMainDS.Clone(); DS = FTempFromDS; AccountCombo = cmbFromAccountCode; } else { DS = FMainDS; AccountCombo = cmbDetailAccountCode; } if (AGrid.Columns.Count == 0) { ATempCombo = new SourceGrid.Cells.Editors.ComboBox(typeof(string)); ATempCombo.EnableEdit = true; ATempCombo.EditableMode = EditableMode.Focus; AGrid.Columns.Clear(); AGrid.AddTextColumn(Catalog.GetString("Type"), FMainDS.ATransAnalAttrib.ColumnAnalysisTypeCode, 99); AGrid.AddTextColumn(Catalog.GetString("Value"), DS.ATransAnalAttrib.Columns[ATransAnalAttribTable.GetAnalysisAttributeValueDBName()], 150, ATempCombo); } FAnalysisAttributesLogic.SetTransAnalAttributeDefaultView(DS); DS.ATransAnalAttrib.DefaultView.AllowNew = false; AGrid.DataSource = new DevAge.ComponentModel.BoundDataView(DS.ATransAnalAttrib.DefaultView); AGrid.SetHeaderTooltip(0, Catalog.GetString("Type")); AGrid.SetHeaderTooltip(1, Catalog.GetString("Value")); AGrid.Selection.SelectionChanged += AnalysisAttributesGrid_RowSelected; //Prepare Analysis attributes grid to highlight inactive analysis codes // Create a cell view for special conditions SourceGrid.Cells.Views.Cell strikeoutCell2 = new SourceGrid.Cells.Views.Cell(); strikeoutCell2.Font = new System.Drawing.Font(AGrid.Font, FontStyle.Strikeout); // Create a condition, apply the view when true, and assign a delegate to handle it SourceGrid.Conditions.ConditionView conditionAnalysisCodeActive = new SourceGrid.Conditions.ConditionView(strikeoutCell2); conditionAnalysisCodeActive.EvaluateFunction = delegate(SourceGrid.DataGridColumn column2, int gridRow2, object itemRow2) { DataRowView row2 = (DataRowView)itemRow2; string analysisCode = row2[ATransAnalAttribTable.ColumnAnalysisTypeCodeId].ToString(); return(!FAnalysisAttributesLogic.AnalysisCodeIsActive(AccountCombo.GetSelectedString(), FCacheDS.AAnalysisAttribute, analysisCode)); }; // Create a condition, apply the view when true, and assign a delegate to handle it SourceGrid.Conditions.ConditionView conditionAnalysisAttributeValueActive = new SourceGrid.Conditions.ConditionView(strikeoutCell2); conditionAnalysisAttributeValueActive.EvaluateFunction = delegate(SourceGrid.DataGridColumn column2, int gridRow2, object itemRow2) { if (itemRow2 != null) { DataRowView row2 = (DataRowView)itemRow2; string analysisCode = row2[ATransAnalAttribTable.ColumnAnalysisTypeCodeId].ToString(); string analysisAttributeValue = row2[ATransAnalAttribTable.ColumnAnalysisAttributeValueId].ToString(); return(!TAnalysisAttributes.AnalysisAttributeValueIsActive(ref ATempCombo, FCacheDS.AFreeformAnalysis, analysisCode, analysisAttributeValue)); } else { return(false); } }; //Add conditions to columns int indexOfAnalysisCodeColumn = 0; int indexOfAnalysisAttributeValueColumn = 1; AGrid.Columns[indexOfAnalysisCodeColumn].Conditions.Add(conditionAnalysisCodeActive); AGrid.Columns[indexOfAnalysisAttributeValueColumn].Conditions.Add(conditionAnalysisAttributeValueActive); AGridCombo = ATempCombo; }
private void SetupGrid() { // manually add a forth column which displays the fields partner short name DataColumn FieldName = new DataColumn("FieldName", Type.GetType("System.String")); FMainDS.PPartnerGiftDestination.Columns.Add(FieldName); grdDetails.Columns.Clear(); grdDetails.AddDateColumn("Date Effective From", FMainDS.PPartnerGiftDestination.ColumnDateEffective); grdDetails.AddDateColumn("Date of Expiry", FMainDS.PPartnerGiftDestination.ColumnDateExpires); grdDetails.AddPartnerKeyColumn("Field Key", FMainDS.PPartnerGiftDestination.ColumnFieldKey); grdDetails.AddPartnerKeyColumn("Field Name", FieldName); foreach (DataRow Row in FMainDS.PPartnerGiftDestination.Rows) { string PartnerShortName; TPartnerClass PartnerClass; TRemote.MPartner.Partner.ServerLookups.WebConnectors.GetPartnerShortName( Convert.ToInt64(Row[PPartnerGiftDestinationTable.ColumnFieldKeyId]), out PartnerShortName, out PartnerClass); Row["FieldName"] = PartnerShortName; } // create a new column so we can to sort the table with null DateExpires values at the top DataColumn NewColumn = new DataColumn("Order", Type.GetType("System.DateTime")); FMainDS.PPartnerGiftDestination.Columns.Add(NewColumn); foreach (DataRow Row in FMainDS.PPartnerGiftDestination.Rows) { if (Row["p_date_expires_d"] == DBNull.Value) { Row["Order"] = DateTime.MaxValue; } else { Row["Order"] = Row["p_date_expires_d"]; } } DataView myDataView = FMainDS.PPartnerGiftDestination.DefaultView; myDataView.Sort = "Order DESC, p_date_effective_d DESC"; myDataView.AllowNew = false; grdDetails.DataSource = new DevAge.ComponentModel.BoundDataView(myDataView); grdDetails.Columns.AutoSize(false); //Prepare grid to highlight inactive Gift Destinations SourceGrid.Cells.Views.Cell strikeoutCell = new SourceGrid.Cells.Views.Cell(); strikeoutCell.Font = new System.Drawing.Font(grdDetails.Font, FontStyle.Strikeout); // Create a condition, apply the view when true, and assign a delegate to handle it SourceGrid.Conditions.ConditionView condition = new SourceGrid.Conditions.ConditionView(strikeoutCell); condition.EvaluateFunction = delegate(SourceGrid.DataGridColumn column, int gridRow, object itemRow) { DataRowView row = (DataRowView)itemRow; if (row[PPartnerGiftDestinationTable.ColumnDateEffectiveId].ToString() == row[PPartnerGiftDestinationTable.ColumnDateExpiresId].ToString()) { return(true); } return(false); }; // add condtion to grid columns grdDetails.Columns[0].Conditions.Add(condition); grdDetails.Columns[1].Conditions.Add(condition); grdDetails.Columns[2].Conditions.Add(condition); grdDetails.Columns[3].Conditions.Add(condition); }
/// <summary> /// add a column that shows a currency value. /// aligns the value to the right. /// prints number in red if it is negative /// </summary> /// <param name="AColumnTitle">Title of the HeaderColumn</param> /// <param name="ADataColumn">DataColumn to which this column should be DataBound</param> /// <param name="ADecimalDigits">Number of digits after the currency decimal point</param> public void AddCurrencyColumn(String AColumnTitle, DataColumn ADataColumn, int ADecimalDigits) { SourceGrid.Cells.Editors.TextBox CurrencyEditor = new SourceGrid.Cells.Editors.TextBox(typeof(decimal)); CurrencyEditor.TypeConverter = new Ict.Common.TypeConverter.TCurrencyConverter( ADataColumn.ColumnName, Thread.CurrentThread.CurrentCulture.NumberFormat, ADecimalDigits); CurrencyEditor.EditableMode = EditableMode.None; // Non-negative value View SourceGrid.Cells.Views.Cell view = new SourceGrid.Cells.Views.Cell(); view.TextAlignment = DevAge.Drawing.ContentAlignment.MiddleRight; // Negative value View SourceGrid.Cells.Views.Cell NegativeNumberView = new SourceGrid.Cells.Views.Cell(); NegativeNumberView.TextAlignment = DevAge.Drawing.ContentAlignment.MiddleRight; NegativeNumberView.ForeColor = Color.Red; // Condition for negative value View SourceGrid.Conditions.ConditionView selectedConditionNegative = new SourceGrid.Conditions.ConditionView(NegativeNumberView); selectedConditionNegative.EvaluateFunction = (delegate(SourceGrid.DataGridColumn column, int gridRow, object itemRow) { DataRowView row = (DataRowView)itemRow; return row[ADataColumn.ColumnName] is decimal && (decimal)row[ADataColumn.ColumnName] < 0; }); AddTextColumn(AColumnTitle, ADataColumn, -1, null, CurrencyEditor, null, view, selectedConditionNegative); }