private void frmSample14_Load(object sender, System.EventArgs e) { grid.BorderStyle = BorderStyle.FixedSingle; grid.ColumnsCount = 4; grid.FixedRows = 1; grid.Rows.Insert(0); SourceGrid.Cells.Editors.ComboBox cbEditor = new SourceGrid.Cells.Editors.ComboBox(typeof(string)); cbEditor.StandardValues = new string[] { "Value 1", "Value 2", "Value 3" }; cbEditor.EditableMode = SourceGrid.EditableMode.Focus | SourceGrid.EditableMode.SingleClick | SourceGrid.EditableMode.AnyKey; grid[0, 0] = new SourceGrid.Cells.ColumnHeader("String"); grid[0, 1] = new SourceGrid.Cells.ColumnHeader("DateTime"); grid[0, 2] = new SourceGrid.Cells.ColumnHeader("CheckBox"); grid[0, 3] = new SourceGrid.Cells.ColumnHeader("ComboBox"); for (int r = 1; r < 10; r++) { grid.Rows.Insert(r); grid[r, 0] = new SourceGrid.Cells.Cell("Hello " + r.ToString(), typeof(string)); grid[r, 1] = new SourceGrid.Cells.Cell(DateTime.Today, typeof(DateTime)); grid[r, 2] = new SourceGrid.Cells.CheckBox(null, true); grid[r, 3] = new SourceGrid.Cells.Cell("Value 1", cbEditor); grid[r, 3].View = SourceGrid.Cells.Views.ComboBox.Default; } grid.AutoSizeCells(); }
private void frmSample54_Load(object sender, System.EventArgs e) { grid1.BorderStyle = BorderStyle.FixedSingle; grid1.ColumnsCount = 4; grid1.FixedRows = 1; grid1.Rows.Insert(0); grid1.Selection.FocusStyle = FocusStyle.None; cbEditor = new SourceGrid.Cells.Editors.ComboBox(typeof(string)); cbEditor.StandardValues = new string[] { "Value 1", "Value 2", "Value 3" }; cbEditor.EditableMode = SourceGrid.EditableMode.Focus | SourceGrid.EditableMode.SingleClick | SourceGrid.EditableMode.AnyKey; grid1[0, 0] = new SourceGrid.Cells.ColumnHeader("String"); grid1[0, 1] = new SourceGrid.Cells.ColumnHeader("DateTime"); grid1[0, 2] = new SourceGrid.Cells.ColumnHeader("CheckBox"); grid1[0, 3] = new SourceGrid.Cells.ColumnHeader("ComboBox"); for (int r = 1; r < 10; r++) { grid1.Rows.Insert(r); PopulateRow(r); } grid1.AutoSizeCells(); numericUpDownRowIndex.Value = 0; numericUpDownRowIndex.Minimum = 1; numericUpDownRowIndex.Value = 3; buttonEditCell.Click += delegate { StartEdit(grid1.Selection.ActivePosition); }; }
private void InitializeSourceGrid() { this.dataGrid.Rows.RowHeight = 21; //處理第一列中文字體會被遮住的問題 this.dataGrid.Columns.Add("Comment", "參數", typeof(string)); this.dataGrid.Columns.Add("Value", "數值", typeof(string)); this.dataGrid.Columns[0].Width = 180; this.dataGrid.Columns[0].DataCell.Model.AddModel(new BoundImage()); this.dataGrid.Columns[0].DataCell.Editor.EnableEdit = false; this.dataGrid.Columns[1].Width = 175; //修改選擇條的框線寬度與顏色 SourceGrid.Selection.SelectionBase cSelectionBase = this.dataGrid.Selection as SourceGrid.Selection.SelectionBase; cSelectionBase.Border = new DevAge.Drawing.RectangleBorder(new DevAge.Drawing.BorderLine(cSelectionBase.BackColor, 1)); //建立必要的 Editor 控制項 __cTextBox = this.dataGrid.Columns[1].DataCell.Editor; //保存原始 Editor 控制像 __cTextBox.NullString = null; __cComboBox = new SourceGrid.Cells.Editors.ComboBox(typeof(string), __sBooleans, true); __cComboBox.AllowNull = false; //建立資料來源 source = new Data.SimpleBoundList <Data._ParameterInfo>(64); source.AllowEdit = true; this.dataGrid.DataSource = source; }
/// <summary> /// /// </summary> /// <param name="AGridCombo"></param> /// <param name="AAnalysisAttribute"></param> /// <param name="AAnalysisCode"></param> /// <param name="AAnalysisAttributeValue"></param> /// <returns></returns> public static bool AnalysisAttributeValueIsActive(ref SourceGrid.Cells.Editors.ComboBox AGridCombo, AFreeformAnalysisTable AAnalysisAttribute, String AAnalysisCode = "", String AAnalysisAttributeValue = "") { bool retVal = true; if ((AAnalysisCode == string.Empty) || (AAnalysisAttributeValue == string.Empty)) { return(retVal); } DataView dv = new DataView(AAnalysisAttribute); dv.RowFilter = String.Format("{0}='{1}' AND {2}='{3}' AND {4}=true", AFreeformAnalysisTable.GetAnalysisTypeCodeDBName(), AAnalysisCode, AFreeformAnalysisTable.GetAnalysisValueDBName(), AAnalysisAttributeValue, AFreeformAnalysisTable.GetActiveDBName()); retVal = (dv.Count > 0); //Make sure the grid combobox has right font else it will adopt strikeout // for all items in the list. AGridCombo.Control.Font = new Font(FontFamily.GenericSansSerif, 8); return(retVal); }
private void frmSample14_Load(object sender, System.EventArgs e) { grid1.BorderStyle = BorderStyle.FixedSingle; grid1.ColumnsCount = 4; grid1.FixedRows = 1; grid1.Rows.Insert(0); SourceGrid.Cells.Editors.ComboBox cbEditor = new SourceGrid.Cells.Editors.ComboBox(typeof(string)); cbEditor.StandardValues = new string[]{"Value 1", "Value 2", "Value 3"}; cbEditor.EditableMode = SourceGrid.EditableMode.Focus | SourceGrid.EditableMode.SingleClick | SourceGrid.EditableMode.AnyKey; grid1[0, 0] = new SourceGrid.Cells.ColumnHeader("String"); grid1[0, 1] = new SourceGrid.Cells.ColumnHeader("DateTime"); grid1[0, 2] = new SourceGrid.Cells.ColumnHeader("CheckBox"); grid1[0, 3] = new SourceGrid.Cells.ColumnHeader("ComboBox"); for (int r = 1; r < 10; r++) { grid1.Rows.Insert(r); grid1[r, 0] = new SourceGrid.Cells.Cell("Hello " + r.ToString(), typeof(string)); grid1[r, 1] = new SourceGrid.Cells.Cell(DateTime.Today, typeof(DateTime)); grid1[r, 2] = new SourceGrid.Cells.CheckBox(null, true); grid1[r, 3] = new SourceGrid.Cells.Cell("Value 1", cbEditor); grid1[r, 3].View = SourceGrid.Cells.Views.ComboBox.Default; } grid1.AutoSizeCells(); }
public void AddEmptyRow() { int newRowIndex = Rows.Count; Rows.Insert(newRowIndex); SuplementTypeCellValueChangedController suplementController = new SuplementTypeCellValueChangedController(this, entry); var lookupEditor = new LookupEditEditor(typeof(Guid)); this[newRowIndex, SuplementTypeColumn] = new SourceGrid.Cells.Cell(null, lookupEditor); SourceGrid.Cells.Views.Cell readOnlyView = new SourceGrid.Cells.Views.Cell(); this[newRowIndex, SuplementTypeColumn].View = readOnlyView; this[newRowIndex, SuplementTypeColumn].View.ForeColor = ApplicationColors.FGNullText; this[newRowIndex, SuplementTypeColumn].AddController(suplementController); this[newRowIndex, SuplementTypeColumn].Editor.NullDisplayString = SuplementsEntryStrings.SelectSuplementType; readOnlyView = new SourceGrid.Cells.Views.Cell(); var textBox = new SourceGrid.Cells.Editors.TextBox(typeof(string)); textBox.Control.MaxLength = Constants.NameColumnLength; this[newRowIndex, SuplementNameColumn] = new SourceGrid.Cells.Cell(null, textBox); this[newRowIndex, SuplementNameColumn].View = readOnlyView; readOnlyView = new SourceGrid.Cells.Views.Cell(); ////grid1[newRowIndex, 1].AddController(ee); this[newRowIndex, InfoColumn] = new SourceGrid.Cells.Cell(null, new MemoExEditEditor()); this[newRowIndex, InfoColumn].View = readOnlyView; this[newRowIndex, InfoColumn].AddController(commentableCellController); this[newRowIndex, InfoColumn].Column.Width = 80; var maskEditor = new MaskEditEditor(); maskEditor.MaskRegEx = string.Format("[0-9]*{0}?[0-9]*", System.Globalization.CultureInfo.CurrentCulture.NumberFormat.NumberDecimalSeparator); this[newRowIndex, DosageColumn] = new SourceGrid.Cells.Cell(null, maskEditor); this[newRowIndex, DosageColumn].View = readOnlyView; SourceGrid.Cells.Editors.ComboBox cbEditor = new SourceGrid.Cells.Editors.ComboBox(typeof(ComboBoxItem)); //cbEditor.StandardValues = Enum.GetValues(typeof (DosageType)); foreach (DosageType type in Enum.GetValues(typeof(DosageType))) { cbEditor.Control.Items.Add(new BodyArchitect.Controls.ComboBoxItem(type, EnumLocalizer.Default.Translate(type))); } cbEditor.Control.DropDownStyle = ComboBoxStyle.DropDownList; this[newRowIndex, DosageTypeColumn] = new SourceGrid.Cells.Cell(null, cbEditor); this[newRowIndex, DosageTypeColumn].View = readOnlyView; this[newRowIndex, DosageTypeColumn].Column.Width = 80; var timeEditor = new TimeEditEditor(); this[newRowIndex, TimeColumn] = new SourceGrid.Cells.Cell(null, timeEditor); this[newRowIndex, TimeColumn].View = new TimeEditView(); UpdateCellsReadOnlyMode(Rows[newRowIndex]); }
private void OnRemoveRow(object sender, EventArgs e) { foreach (int row in grid.Selection.GetSelectionRegion().GetRowsIndex()) { if (grid[row, 1].Editor is SourceGrid.Cells.Editors.ComboBox) { SourceGrid.Cells.Editors.ComboBox combo = grid[row, 1].Editor as SourceGrid.Cells.Editors.ComboBox; combo.Control.SelectionChangeCommitted -= new EventHandler(OnChannelTypeChanged); } grid.Rows.Remove(row); } }
public void AddEmptyRow() { int newRowIndex = grid1.Rows.Count; grid1.Rows.Insert(newRowIndex); var lookupEditor = new LookupEditEditor(typeof(Guid)); LookUpColumnInfo selectedCol = (LookUpColumnInfo)((ComboBoxItem)cmbExerciseViewType.SelectedItem).Tag; lookupEditor.Control.SetDisplayColumn(selectedCol); grid1[newRowIndex, FromExerciseColumn] = new SourceGrid.Cells.Cell(null, lookupEditor); SourceGrid.Cells.Views.Cell readOnlyView = new SourceGrid.Cells.Views.Cell(); grid1[newRowIndex, FromExerciseColumn].View = readOnlyView; grid1[newRowIndex, FromExerciseColumn].View.ForeColor = ApplicationColors.FGNullText; grid1[newRowIndex, FromExerciseColumn].AddController(mapperCtrl); grid1[newRowIndex, FromExerciseColumn].Editor.NullDisplayString = StrengthTrainingEntryStrings.SelectExercise; grid1[newRowIndex, FromExerciseColumn].Column.Width = 250; readOnlyView = new SourceGrid.Cells.Views.Cell(); lookupEditor = new LookupEditEditor(typeof(Guid)); lookupEditor.Control.SetDisplayColumn(selectedCol); grid1[newRowIndex, ToExerciseColumn] = new SourceGrid.Cells.Cell(null, lookupEditor); readOnlyView = new SourceGrid.Cells.Views.Cell(); grid1[newRowIndex, ToExerciseColumn].View = readOnlyView; grid1[newRowIndex, ToExerciseColumn].View.ForeColor = ApplicationColors.FGNullText; grid1[newRowIndex, ToExerciseColumn].AddController(mapperCtrl); grid1[newRowIndex, ToExerciseColumn].Editor.NullDisplayString = StrengthTrainingEntryStrings.SelectExercise; grid1[newRowIndex, ToExerciseColumn].Column.Width = 250; SourceGrid.Cells.Editors.ComboBox cbEditor = new SourceGrid.Cells.Editors.ComboBox(typeof(ComboBoxItem)); //cbEditor.StandardValues = Enum.GetValues(typeof(MapperEntryOperation)); foreach (MapperEntryOperation type in Enum.GetValues(typeof(MapperEntryOperation))) { cbEditor.Control.Items.Add(new ComboBoxItem(type, EnumLocalizer.Default.Translate(type))); } cbEditor.Control.DropDownStyle = ComboBoxStyle.DropDownList; cbEditor.Control.SelectedIndex = 0; readOnlyView = new SourceGrid.Cells.Views.Cell(); grid1[newRowIndex, OperationColumn] = new SourceGrid.Cells.Cell(null, cbEditor); grid1[newRowIndex, OperationColumn].View = readOnlyView; grid1[newRowIndex, OperationColumn].Column.Width = 80; UpdateCellsReadOnlyMode(grid1.Rows[newRowIndex]); }
private void AddVariable(string variableName, string type, double interval) { int row = grid.RowsCount; grid.RowsCount++; grid[row, 0] = new SourceGrid.Cells.Cell(variableName, typeof(string)); SourceGrid.Cells.Editors.ComboBox combo = new SourceGrid.Cells.Editors.ComboBox(typeof(string), channelNames, true); grid[row, 1] = new SourceGrid.Cells.Cell(variableTypeNames[type], combo); grid[row, 2] = new SourceGrid.Cells.Cell(interval, typeof(double)); grid.Selection.ResetSelection(true); grid.Selection.SelectRow(row, true); }
protected override void OnLoad(EventArgs e) { base.OnLoad(e); grid1.Redim(30, 2); grid1[0, 0] = new SourceGrid.Cells.ColumnHeader("Checked"); grid1[0, 1] = new SourceGrid.Cells.ColumnHeader("CheckStatus"); SourceGrid.Cells.Editors.ComboBox combo = new SourceGrid.Cells.Editors.ComboBox(typeof(DevAge.Drawing.CheckBoxState)); DependencyColumn boolToStatus = new DependencyColumn(1); boolToStatus.ConvertFunction = delegate(object valBool) { if (valBool == null) return DevAge.Drawing.CheckBoxState.Undefined; else if ((bool)valBool == true) return DevAge.Drawing.CheckBoxState.Checked; else return DevAge.Drawing.CheckBoxState.Unchecked; }; DependencyColumn statusToBool = new DependencyColumn(0); statusToBool.ConvertFunction = delegate(object valStatus) { DevAge.Drawing.CheckBoxState status = (DevAge.Drawing.CheckBoxState)valStatus; if (status == DevAge.Drawing.CheckBoxState.Undefined) return null; else if (status == DevAge.Drawing.CheckBoxState.Checked) return true; else return false; }; for (int r = 1; r < grid1.RowsCount; r++) { grid1[r, 0] = new SourceGrid.Cells.CheckBox(null, null); grid1[r, 0].Editor.AllowNull = true; grid1[r, 0].AddController(boolToStatus); grid1[r, 1] = new SourceGrid.Cells.Cell(DevAge.Drawing.CheckBoxState.Undefined, combo); grid1[r, 1].AddController(statusToBool); } grid1.AutoSizeCells(); }
internal void PopulateTemperatures(string tempCmdStr, Grid gridTemps) { Dictionary <int, int> tempDict = new Dictionary <int, int>(); List <string> tempLines = bfbObject.getTemperatures(tempCmdStr); for (int i = 0; i < tempLines.Count; i++) { int temperature = bfbObject.GetTemperatureFromString(tempLines[i]); if (tempDict.ContainsKey(temperature)) { tempDict[temperature]++; } else { tempDict.Add(temperature, 1); } } SourceGrid.Cells.Editors.ComboBox tempModEditor; String[] tempModType = { "Percentage", "Additive", "Replace" }; tempModEditor = new SourceGrid.Cells.Editors.ComboBox(typeof(String)); tempModEditor.StandardValues = tempModType; tempModEditor.EditableMode = SourceGrid.EditableMode.Focus | SourceGrid.EditableMode.SingleClick | SourceGrid.EditableMode.AnyKey; SourceGrid.Cells.Editors.TextBox tempCountEditor = new SourceGrid.Cells.Editors.TextBox(typeof(int)); tempCountEditor.EditableMode = SourceGrid.EditableMode.None; int gridRow = 1; TemperatureChangedEvent valueChangedController = new TemperatureChangedEvent(this); foreach (int temp in tempDict.Keys) { gridTemps.Rows.Insert(gridRow); gridTemps[gridRow, 0] = new SourceGrid.Cells.Cell(temp, tempCountEditor); gridTemps[gridRow, 1] = new SourceGrid.Cells.Cell(tempDict[temp], tempCountEditor); gridTemps[gridRow, 2] = new SourceGrid.Cells.Cell(null, typeof(int)); gridTemps[gridRow, 2].AddController(valueChangedController); gridTemps[gridRow, 3] = new SourceGrid.Cells.Cell("Replace", tempModEditor); gridTemps[gridRow, 3].View = SourceGrid.Cells.Views.ComboBox.Default; gridTemps[gridRow, 3].AddController(valueChangedController); gridTemps[gridRow, 4] = new SourceGrid.Cells.Cell(0, tempCountEditor); //gridLeftTemps[gridRow, 1] = new SourceGrid.Cells.CellControl(); gridRow++; } }
private void FillGrid(Grid grid, List <UInt32[]> Data, List <string> ColumnNames) { grid.BorderStyle = BorderStyle.FixedSingle; grid.ColumnsCount = ColumnNames.Count; grid.FixedRows = 1; grid.Rows.Insert(0); SourceGrid.Cells.Editors.ComboBox cbEditor = new SourceGrid.Cells.Editors.ComboBox(typeof(string)); cbEditor.StandardValues = new string[] { "Value 1", "Value 2", "Value 3" }; cbEditor.EditableMode = SourceGrid.EditableMode.Focus | SourceGrid.EditableMode.SingleClick | SourceGrid.EditableMode.AnyKey; int p = 0; foreach (var _column in ColumnNames) { grid[0, p] = new SourceGrid.Cells.ColumnHeader(_column); grid.Columns.SetWidth(p, 100); p++; } grid.Rows.Insert(1); grid.Rows[1].Height = dgvSgtFile.Height - 50; for (int q = 0; q < ColumnNames.Count; q++) { //ZedGraphControl ZDC = new ZedGraphControl(); //ZDC.GraphPane.Title.Text = ""; //ZDC.GraphPane.XAxis.Title.Text = ""; //ZDC.GraphPane.YAxis.Title.Text = ""; //CreateGraph(ZDC, GetSignal(Data, q)); PlotterDisplayEx PDE = new PlotterDisplayEx(); PDE.Smoothing = System.Drawing.Drawing2D.SmoothingMode.None; PDE.Refresh(); BuildGraph(PDE, GetSignal(Data, q)); grid[1, q] = new SourceGrid.Cells.CellControl(PDE); } //grid.AutoSizeCells(); }
private void AddVariable(string variableName, string type, bool readOnly) { int row = grid.RowsCount; grid.RowsCount++; grid[row, 0] = new SourceGrid.Cells.Cell(variableName, typeof(string)); SourceGrid.Cells.Editors.ComboBox combo = new SourceGrid.Cells.Editors.ComboBox(typeof(string), channelNames, true); combo.Control.Sorted = true; combo.Control.DropDownStyle = ComboBoxStyle.DropDownList; combo.Control.SelectionChangeCommitted += new EventHandler(OnChannelTypeChanged); grid[row, 1] = new SourceGrid.Cells.Cell(variableTypeNames[type], combo); SourceGrid.Cells.CheckBox check = new SourceGrid.Cells.CheckBox(); check.Checked = readOnly; grid[row, 2] = check; grid.Selection.ResetSelection(true); grid.Selection.SelectRow(row, true); }
/// <summary> /// load the transactions into the grid /// </summary> /// <param name="ALedgerNumber"></param> /// <param name="ABatchNumber"></param> /// <param name="AJournalNumber"></param> /// <param name="ACurrencyCode"></param> /// <param name="AFromBatchTab"></param> /// <param name="ABatchStatus"></param> /// <param name="AJournalStatus"></param> /// <returns>True if new GL transactions were loaded, false if transactions had been loaded already.</returns> public bool LoadTransactions(Int32 ALedgerNumber, Int32 ABatchNumber, Int32 AJournalNumber, string ACurrencyCode, bool AFromBatchTab = false, string ABatchStatus = MFinanceConstants.BATCH_UNPOSTED, string AJournalStatus = MFinanceConstants.BATCH_UNPOSTED) { TFrmStatusDialog dlgStatus = null; bool DifferentBatchSelected = false; FLoadCompleted = false; FBatchRow = GetBatchRow(); FJournalRow = GetJournalRow(); if ((FBatchRow == null) || (FJournalRow == null)) { return false; } //FBatchNumber and FJournalNumber may have already been set outside // so need to reset to previous value if ((txtBatchNumber.Text.Length > 0) && (FBatchNumber.ToString() != txtBatchNumber.Text)) { FBatchNumber = Int32.Parse(txtBatchNumber.Text); } if ((txtJournalNumber.Text.Length > 0) && (FJournalNumber.ToString() != txtJournalNumber.Text)) { FJournalNumber = Int32.Parse(txtJournalNumber.Text); } bool FirstRun = (FLedgerNumber != ALedgerNumber); bool BatchChanged = (FBatchNumber != ABatchNumber); bool BatchStatusChanged = (!BatchChanged && (FBatchStatus != ABatchStatus)); bool JournalChanged = (BatchChanged || (FJournalNumber != AJournalNumber)); bool JournalStatusChanged = (!JournalChanged && (FJournalStatus != AJournalStatus)); bool CurrencyChanged = (FTransactionCurrency != ACurrencyCode); if (FirstRun) { FLedgerNumber = ALedgerNumber; } if (BatchChanged) { FBatchNumber = ABatchNumber; } if (BatchStatusChanged) { FBatchStatus = ABatchStatus; } if (JournalChanged) { FJournalNumber = AJournalNumber; } if (JournalStatusChanged) { FJournalStatus = AJournalStatus; } if (CurrencyChanged) { FTransactionCurrency = ACurrencyCode; } FIsUnposted = (FBatchRow.BatchStatus == MFinanceConstants.BATCH_UNPOSTED); if (FirstRun) { InitialiseControls(); } try { this.Cursor = Cursors.WaitCursor; //Check if the same batch and journal is selected, so no need to apply filter if (!FirstRun && !BatchChanged && !JournalChanged && !BatchStatusChanged && !JournalStatusChanged && !CurrencyChanged && (FMainDS.ATransaction.DefaultView.Count > 0)) { //Same as previously selected batch and journal //Need to reconnect FPrev in some circumstances if (FPreviouslySelectedDetailRow == null) { DataRowView rowView = (DataRowView)grdDetails.Rows.IndexToDataSourceRow(FPrevRowChangedRow); if (rowView != null) { FPreviouslySelectedDetailRow = (GLBatchTDSATransactionRow)(rowView.Row); } } if (FIsUnposted && (GetSelectedRowIndex() > 0)) { if (AFromBatchTab) { SelectRowInGrid(GetSelectedRowIndex()); } else { GetDetailsFromControls(FPreviouslySelectedDetailRow); } } FLoadCompleted = true; return false; } // Different batch selected DifferentBatchSelected = true; bool requireControlSetup = (FLedgerNumber == -1) || (FTransactionCurrency != ACurrencyCode); //Handle dialog dlgStatus = new TFrmStatusDialog(FPetraUtilsObject.GetForm()); if (FShowStatusDialogOnLoad == true) { dlgStatus.Show(); FShowStatusDialogOnLoad = false; dlgStatus.Heading = String.Format(Catalog.GetString("Batch {0}, Journal {1}"), ABatchNumber, AJournalNumber); dlgStatus.CurrentStatus = Catalog.GetString("Loading transactions ..."); } FLedgerNumber = ALedgerNumber; FBatchNumber = ABatchNumber; FJournalNumber = AJournalNumber; FTransactionNumber = -1; FTransactionCurrency = ACurrencyCode; FBatchStatus = ABatchStatus; FJournalStatus = AJournalStatus; FPreviouslySelectedDetailRow = null; grdDetails.SuspendLayout(); //Empty grids before filling them grdDetails.DataSource = null; grdAnalAttributes.DataSource = null; // This sets the main part of the filter but excluding the additional items set by the user GUI // It gets the right sort order SetTransactionDefaultView(); //Set the Analysis attributes filter as well FAnalysisAttributesLogic = new TAnalysisAttributes(FLedgerNumber, FBatchNumber, FJournalNumber); FAnalysisAttributesLogic.SetTransAnalAttributeDefaultView(FMainDS); FMainDS.ATransAnalAttrib.DefaultView.AllowNew = false; //Load from server if necessary if (FMainDS.ATransaction.DefaultView.Count == 0) { dlgStatus.CurrentStatus = Catalog.GetString("Requesting transactions from server..."); FMainDS.Merge(TRemote.MFinance.GL.WebConnectors.LoadATransactionATransAnalAttrib(ALedgerNumber, ABatchNumber, AJournalNumber)); } else if (FMainDS.ATransAnalAttrib.DefaultView.Count == 0) // just in case transactions have been loaded in a separate process without analysis attributes { dlgStatus.CurrentStatus = Catalog.GetString("Requesting analysis attributes from server..."); FMainDS.Merge(TRemote.MFinance.GL.WebConnectors.LoadATransAnalAttribForJournal(ALedgerNumber, ABatchNumber, AJournalNumber)); } FContainsSystemGenerated = false; // check if any of the rows are system generated (i.e. reversals) foreach (DataRowView rv in FMainDS.ATransaction.DefaultView) { if (((ATransactionRow)rv.Row).SystemGenerated) { FContainsSystemGenerated = true; break; } } // We need to call this because we have not called ShowData(), which would have set it. This differs from the Gift screen. grdDetails.DataSource = new DevAge.ComponentModel.BoundDataView(FMainDS.ATransaction.DefaultView); // Now we set the full filter dlgStatus.CurrentStatus = Catalog.GetString("Selecting the records..."); FFilterAndFindObject.ApplyFilter(); dlgStatus.CurrentStatus = Catalog.GetString("Configuring analysis attributes ..."); if (grdAnalAttributes.Columns.Count == 1) { grdAnalAttributes.SpecialKeys = GridSpecialKeys.Default | GridSpecialKeys.Tab; FcmbAnalAttribValues = new SourceGrid.Cells.Editors.ComboBox(typeof(string)); FcmbAnalAttribValues.EnableEdit = true; FcmbAnalAttribValues.EditableMode = EditableMode.Focus; grdAnalAttributes.AddTextColumn(Catalog.GetString("Value"), FMainDS.ATransAnalAttrib.Columns[ATransAnalAttribTable.GetAnalysisAttributeValueDBName()], 150, FcmbAnalAttribValues); FcmbAnalAttribValues.Control.SelectedValueChanged += new EventHandler(this.AnalysisAttributeValueChanged); grdAnalAttributes.Columns[0].Width = 99; } grdAnalAttributes.DataSource = new DevAge.ComponentModel.BoundDataView(FMainDS.ATransAnalAttrib.DefaultView); grdAnalAttributes.SetHeaderTooltip(0, Catalog.GetString("Type")); grdAnalAttributes.SetHeaderTooltip(1, Catalog.GetString("Value")); // if this form is readonly or batch is posted, then we need all account and cost centre codes, because old codes might have been used bool ActiveOnly = false; //(this.Enabled && FIsUnposted && !FContainsSystemGenerated); if (requireControlSetup || (FActiveOnly != ActiveOnly)) { FActiveOnly = ActiveOnly; //Load all analysis attribute values if (FCacheDS == null) { dlgStatus.CurrentStatus = Catalog.GetString("Loading analysis attributes ..."); FCacheDS = TRemote.MFinance.GL.WebConnectors.LoadAAnalysisAttributes(FLedgerNumber, FActiveOnly); } SetupExtraGridFunctionality(); dlgStatus.CurrentStatus = Catalog.GetString("Initialising accounts and cost centres ..."); // We suppress change detection because these are the correct values // Then initialise our combo boxes for the correct account codes and cost centres bool prevSuppressChangeDetection = FPetraUtilsObject.SuppressChangeDetection; FPetraUtilsObject.SuppressChangeDetection = true; TFinanceControls.InitialiseAccountList(ref cmbDetailAccountCode, FLedgerNumber, true, false, ActiveOnly, false, ACurrencyCode, true); TFinanceControls.InitialiseCostCentreList(ref cmbDetailCostCentreCode, FLedgerNumber, true, false, ActiveOnly, false); FPetraUtilsObject.SuppressChangeDetection = prevSuppressChangeDetection; cmbDetailCostCentreCode.AttachedLabel.Text = TFinanceControls.SELECT_VALID_COST_CENTRE; cmbDetailAccountCode.AttachedLabel.Text = TFinanceControls.SELECT_VALID_ACCOUNT; } UpdateTransactionTotals(); grdDetails.ResumeLayout(); FLoadCompleted = true; ShowData(); SelectRowInGrid(1); ShowDetails(); //Needed because of how currency is handled UpdateChangeableStatus(); UpdateRecordNumberDisplay(); FFilterAndFindObject.SetRecordNumberDisplayProperties(); //Check for missing analysis attributes and their values if (FIsUnposted && (grdDetails.Rows.Count > 1)) { string updatedTransactions = string.Empty; dlgStatus.CurrentStatus = Catalog.GetString("Checking analysis attributes ..."); FAnalysisAttributesLogic.ReconcileTransAnalysisAttributes(FMainDS, FCacheDS, out updatedTransactions); if (updatedTransactions.Length > 0) { //Remove trailing comma updatedTransactions = updatedTransactions.Remove(updatedTransactions.Length - 2); MessageBox.Show(String.Format(Catalog.GetString( "Analysis Attributes have been updated in transaction(s): {0}.{1}{1}Remeber to set their values before posting!"), updatedTransactions, Environment.NewLine), "Analysis Attributes", MessageBoxButtons.OK, MessageBoxIcon.Information); FPetraUtilsObject.SetChangedFlag(); } } RefreshAnalysisAttributesGrid(); } catch (Exception ex) { TLogging.Log(String.Format("Method:{0} - Unexpected error!{1}{1}{2}", Utilities.GetMethodSignature(), Environment.NewLine, ex.Message)); throw ex; } finally { if (dlgStatus != null) { dlgStatus.Close(); } this.Cursor = Cursors.Default; } return DifferentBatchSelected; }
void LoadTables(Database db, SourceGrid.Grid grid, string title, string nameTitle, NodeBase tableViewNode) { var tc = new TimerCount("LoadTables"); grid.BorderStyle = BorderStyle.FixedSingle; grid.SelectionMode = SourceGrid.GridSelectionMode.Cell; grid.ClipboardMode = SourceGrid.ClipboardMode.All; grid.Rows.Clear(); grid.Columns.Clear(); grid.ColumnsCount = 11; grid.FixedRows = 1; grid.FixedColumns = 2; //int r = 0; SourceGrid.Cells.Views.Cell categoryView = new SourceGrid.Cells.Views.Cell(); categoryView.Background = new DevAge.Drawing.VisualElements.BackgroundLinearGradient(Color.Gainsboro, Color.WhiteSmoke, 0); categoryView.ForeColor = Color.Black; categoryView.TextAlignment = DevAge.Drawing.ContentAlignment.MiddleCenter; categoryView.Border = DevAge.Drawing.RectangleBorder.NoBorder; categoryView.Font = new Font(Font, FontStyle.Bold); //grid.Rows.Insert(r); //grid[r, 0] = new SourceGrid.Cells.Cell(title); //grid[r, 0].View = categoryView; //grid[r, 0].ColumnSpan = grid.ColumnsCount; //r++; int r = 0; grid.Rows.Insert(r); headerView = new SourceGrid.Cells.Views.Cell(); //headerView.Background = new DevAge.Drawing.VisualElements.BackgroundLinearGradient(Color.Gainsboro, Color.WhiteSmoke, 0); headerView.ForeColor = Color.FromKnownColor(KnownColor.Black); headerView.TextAlignment = DevAge.Drawing.ContentAlignment.MiddleCenter; headerView.Border = DevAge.Drawing.RectangleBorder.NoBorder; headerView.Font = new Font(Font, FontStyle.Bold); addHeader(grid, Col.SchemaName, "Schema Name", 100); addHeader(grid, Col.TableName, "Table Name", 150); addHeader(grid, Col.DataClassName, "DataClass Name", 150); addHeader(grid, Col.BusinessClassName, "BusinessClass Name", 150); addHeader(grid, Col.EnumColumnName, "Enum Column Name", 150); addHeader(grid, Col.EnumColumnId, "Enum Column Id", 150); addHeader(grid, Col.EnumName, "Enum Name", 150); addHeader(grid, Col.EnumAttributes, "Enum Attributes", 150); addHeader(grid, Col.SequenceColumn, "Sequence Column", 150); addHeader(grid, Col.SequenceName, "Sequence Name", 150); addHeader(grid, Col.Attributes, "Attributes", 300); //addHeader(grid, 5, "Sub-directory", 150); for (int c = 0; c < grid.ColumnsCount; c++) { grid[r, c].View = categoryView; } Dictionary <string, GenTable> objects = new Dictionary <string, GenTable>(); tc.Next("GetSequences"); var sequences = db.Provider.GetSequences(); r++; foreach (NodeTable node in tableViewNode.Nodes) { progress.SetProgress(); //progress.SetProgress("Processing table" + node.Text + " ..."); var gtb = node.Item; if (gtb.TableName == "status") { ToString(); } objects.Add(gtb.FullName, null); tc.Next(gtb.TableName); try { //tc.Next("GetTableInfo"); //var tb = db.GetTableInfo(gtb.SchemaName, gtb.TableName); var tbCols = db.GetColumnsInfo(gtb.SchemaName, gtb.TableName); if (tbCols == null) // objeto inválido { continue; } Dictionary <string, GenColumn> dict = new Dictionary <string, GenColumn>(StringComparer.InvariantCultureIgnoreCase); foreach (var col in gtb.Columns) { if (!dict.ContainsKey(col.ColumnName)) { dict.Add(col.ColumnName, col); } } foreach (var col in tbCols) { GenColumn gcol; if (dict.TryGetValue(col.ColumnName, out gcol)) { dict.Remove(col.ColumnName); // remove as existentes // se existe, mas o banco é required, força required; if (!col.IsNullable) { gcol.IsRequired = true; } // o tipo sempre vem do banco gcol.DataType = col.DataTypeDotNet; } else { gcol = new GenColumn(); gcol.ColumnName = col.ColumnName; gcol.PropertyName = null; gcol.Description = null; gcol.IsRequired = !col.IsNullable; gcol.DataType = col.DataTypeDotNet; gtb.Columns.Add(gcol); } } // se sobrou no dict, é pq as colunas foram apagadas da table, ou renomedas foreach (var pair in dict) { gtb.Columns.RemoveAll(p => p.ColumnName.EqualsICIC(pair.Key)); } grid.Rows.Insert(r); //grid.Rows.SetHeight(r, 40); //grid.Rows.AutoSizeRow(r); SourceGrid.GridRow row = grid.Rows[r]; // tags row.AutoSizeMode = SourceGrid.AutoSizeMode.EnableAutoSize | SourceGrid.AutoSizeMode.EnableStretch; row.Tag = node; gtb.Tag = tbCols; node.Tag = row; grid[r, Col.SchemaName] = new SourceGrid.Cells.Cell(gtb.SchemaName); grid[r, Col.TableName] = new SourceGrid.Cells.Cell(gtb.TableName); SourceGrid.Cells.Editors.EditorBase ed; ed = SourceGrid.Cells.Editors.Factory.Create(typeof(string)); ed.EditableMode = SourceGrid.EditableMode.Focus | SourceGrid.EditableMode.SingleClick | SourceGrid.EditableMode.AnyKey; grid[r, Col.DataClassName] = new SourceGrid.Cells.Cell(gtb.DataClassName, ed); ed = SourceGrid.Cells.Editors.Factory.Create(typeof(string)); ed.EditableMode = SourceGrid.EditableMode.Focus | SourceGrid.EditableMode.SingleClick | SourceGrid.EditableMode.AnyKey; grid[r, Col.BusinessClassName] = new SourceGrid.Cells.Cell(gtb.BusinessClassName, ed); // EnumColumnName SourceGrid.Cells.Editors.ComboBox cbEditor = new SourceGrid.Cells.Editors.ComboBox(typeof(string)); var cols = (from c in tbCols where c.DataTypeDotNet.ToLower().Contains("string") orderby c.ColumnName select c.ColumnName).ToList(); if (!string.IsNullOrWhiteSpace(gtb.EnumColumnName)) { if (cols.FirstOrDefault(p => p.ToUpper() == gtb.EnumColumnName) == null) { gtb.EnumColumnName = gtb.EnumColumnId = gtb.EnumName = null; } } else { gtb.EnumColumnName = gtb.EnumColumnId = gtb.EnumName = null; } if (cols.Count > 0) { cols.Insert(0, ""); cbEditor.StandardValues = cols; cbEditor.EditableMode = SourceGrid.EditableMode.Focus | SourceGrid.EditableMode.SingleClick | SourceGrid.EditableMode.AnyKey; } else { cbEditor.EditableMode = SourceGrid.EditableMode.None; } grid[r, Col.EnumColumnName] = new SourceGrid.Cells.Cell(gtb.EnumColumnName, cbEditor); // EnumColumnId cbEditor = new SourceGrid.Cells.Editors.ComboBox(typeof(string)); cols = (from c in tbCols where numericTypes.ContainsKey(c.DataTypeDotNet.Replace("?", "")) orderby c.ColumnName select c.ColumnName).ToList(); if (cols.Count > 0) { cols.Insert(0, ""); cbEditor.StandardValues = cols; cbEditor.EditableMode = SourceGrid.EditableMode.Focus | SourceGrid.EditableMode.SingleClick | SourceGrid.EditableMode.AnyKey; } else { cbEditor.EditableMode = SourceGrid.EditableMode.None; } grid[r, Col.EnumColumnId] = new SourceGrid.Cells.Cell(gtb.EnumColumnId, cbEditor); // EnumName ed = SourceGrid.Cells.Editors.Factory.Create(typeof(string)); ed.EditableMode = SourceGrid.EditableMode.Focus | SourceGrid.EditableMode.SingleClick | SourceGrid.EditableMode.AnyKey; grid[r, Col.EnumName] = new SourceGrid.Cells.Cell(gtb.EnumName, ed); // EnumAttributes ed = SourceGrid.Cells.Editors.Factory.Create(typeof(string)); ed.EditableMode = SourceGrid.EditableMode.Focus | SourceGrid.EditableMode.SingleClick | SourceGrid.EditableMode.AnyKey; grid[r, Col.EnumAttributes] = new SourceGrid.Cells.Cell(gtb.EnumAttributes, ed); // SequenceColumn cbEditor = new SourceGrid.Cells.Editors.ComboBox(typeof(string)); cols = (from c in tbCols where numericTypes.ContainsKey(c.DataTypeDotNet.Replace("?", "")) orderby c.ColumnName select c.ColumnName).ToList(); if (cols.Count > 0) { cols.Insert(0, ""); cbEditor.StandardValues = cols; cbEditor.EditableMode = SourceGrid.EditableMode.Focus | SourceGrid.EditableMode.SingleClick | SourceGrid.EditableMode.AnyKey; } else { cbEditor.EditableMode = SourceGrid.EditableMode.None; } grid[r, Col.SequenceColumn] = new SourceGrid.Cells.Cell(gtb.SequenceColumn, cbEditor); // SequenceName cbEditor = new SourceGrid.Cells.Editors.ComboBox(typeof(string)); if (sequences.Count > 0) { cols.Insert(0, ""); cbEditor.StandardValues = (from c in sequences select c.FullName).ToList(); cbEditor.EditableMode = SourceGrid.EditableMode.Focus | SourceGrid.EditableMode.SingleClick | SourceGrid.EditableMode.AnyKey; } else { cbEditor.EditableMode = SourceGrid.EditableMode.None; } grid[r, Col.SequenceName] = new SourceGrid.Cells.Cell(gtb.SequenceName, cbEditor); var ed2 = SourceGrid.Cells.Editors.Factory.Create(typeof(string)); var txt = (SourceGrid.Cells.Editors.TextBox)ed2; txt.Control.Multiline = true; txt.Control.AcceptsReturn = true; //txt.Control.ScrollBars = ScrollBars.Both; //txt.Control.ImeMode = ImeMode.Disable; ed2.EditableMode = SourceGrid.EditableMode.Focus | SourceGrid.EditableMode.SingleClick | SourceGrid.EditableMode.AnyKey; //if (gtb.Attributes != null) //{ // gtb.Attributes = gtb.Attributes.Replace("\r\n", "\n"); // gtb.Attributes = gtb.Attributes.Replace("\n", "\r\n\r\n"); //} grid[r, Col.Attributes] = new SourceGrid.Cells.Cell(gtb.Attributes, ed2); //ed = SourceGrid.Cells.Editors.Factory.Create(typeof(string)); //ed.EditableMode = SourceGrid.EditableMode.Focus | SourceGrid.EditableMode.SingleClick | SourceGrid.EditableMode.AnyKey; //grid[r, 5] = new SourceGrid.Cells.Cell(gtb.SubDirectory, ed); r++; //string time = tc.ToString(); } catch (Exception ex) { //Program.ShowError(ex); } } // remove objetos não mais existentes na base de dados var objs = tableViewNode is NodeTables ? file.Parameters.Tables : file.Parameters.Views; foreach (var obj in objs.ToList()) { if (!objects.ContainsKey(obj.FullName)) { objs.Remove(obj); } } grid.Selection.FocusRowEntered += Selection_FocusRowEntered; grid.Selection.FocusRowLeaving += Selection_FocusRowLeaving; grid.AutoSizeCells(); string time = tc.ToString(); }
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); } }
// // Called from cmbDetailAccountCode.SelectedValueChanged, // I need to load the Analysis Types Pane with the required attributes for this account, // and show any assignments already made. void ShowAnalysisAttributesForAccount(object sender, EventArgs e) { // // It's possible that my TDS doesn't even have an AnalAttrib table... if (FMainDS.AApAnalAttrib == null) { FMainDS.Merge(new AApAnalAttribTable()); } if (FPetraUtilsObject.SuppressChangeDetection || (FPreviouslySelectedDetailRow == null)) { return; } //Empty the grid FMainDS.AApAnalAttrib.DefaultView.RowFilter = "1=2"; FPSAttributesRow = null; if (grdAnalAttributes.Columns.Count < 2) // This is initialisation but I moved it here because sometimes this is called before Show(). { grdAnalAttributes.SpecialKeys = GridSpecialKeys.Default | GridSpecialKeys.Tab; cmbAnalAttribValues = new SourceGrid.Cells.Editors.ComboBox(typeof(string)); cmbAnalAttribValues.Control.DropDownStyle = ComboBoxStyle.DropDownList; cmbAnalAttribValues.EnableEdit = true; cmbAnalAttribValues.EditableMode = EditableMode.Focus; cmbAnalAttribValues.Control.SelectedValueChanged += new EventHandler(AnalysisAttributeValueChanged); grdAnalAttributes.AddTextColumn("Value", FMainDS.AApAnalAttrib.Columns[AApAnalAttribTable.GetAnalysisAttributeValueDBName()], 120, cmbAnalAttribValues); grdAnalAttributes.Selection.SelectionChanged += new RangeRegionChangedEventHandler(AnalysisAttributesGrid_RowSelected); } grdAnalAttributes.Columns[0].Width = 90; // for some unknown reason, this doesn't work. grdAnalAttributes.Columns[1].Width = 120; AccountsPayableTDSAApDocumentDetailRow DetailRow = GetSelectedDetailRow(); DetailRow.AccountCode = cmbDetailAccountCode.GetSelectedString(); // // So I want to remove any attributes attached to this row that don't have the new account code... FMainDS.AApAnalAttrib.DefaultView.RowFilter = String.Format("{0}={1} AND {2}={3} AND {4}={5} AND {6}<>'{7}'", AApAnalAttribTable.GetLedgerNumberDBName(), DetailRow.LedgerNumber, AApAnalAttribTable.GetApDocumentIdDBName(), DetailRow.ApDocumentId, AApAnalAttribTable.GetDetailNumberDBName(), DetailRow.DetailNumber, AApAnalAttribTable.GetAccountCodeDBName(), DetailRow.AccountCode); for (Int32 RowIdx = FMainDS.AApAnalAttrib.DefaultView.Count; RowIdx > 0; RowIdx--) { FMainDS.AApAnalAttrib.DefaultView[RowIdx - 1].Row.Delete(); } FMainDS.AAnalysisAttribute.DefaultView.RowFilter = String.Format("{0}='{1}'", AAnalysisAttributeTable.GetAccountCodeDBName(), DetailRow.AccountCode); String AccountCodeRowFilter = String.Format("{0}={1} AND {2}={3} AND {4}={5} AND {6}='{7}'", AApAnalAttribTable.GetLedgerNumberDBName(), DetailRow.LedgerNumber, AApAnalAttribTable.GetApDocumentIdDBName(), DetailRow.ApDocumentId, AApAnalAttribTable.GetDetailNumberDBName(), DetailRow.DetailNumber, AApAnalAttribTable.GetAccountCodeDBName(), DetailRow.AccountCode); foreach (DataRowView rv in FMainDS.AAnalysisAttribute.DefaultView) // List of attributes required for this account { AAnalysisAttributeRow AttrRow = (AAnalysisAttributeRow)rv.Row; FMainDS.AApAnalAttrib.DefaultView.RowFilter = AccountCodeRowFilter + String.Format(" AND {0}='{1}'", AApAnalAttribTable.GetAnalysisTypeCodeDBName(), AttrRow.AnalysisTypeCode); if (FMainDS.AApAnalAttrib.DefaultView.Count == 0) // No Entry yet for this attribute. This is likely, given I just deleted everything... { AApAnalAttribRow AARow = FMainDS.AApAnalAttrib.NewRowTyped(); AARow.LedgerNumber = DetailRow.LedgerNumber; AARow.ApDocumentId = DetailRow.ApDocumentId; AARow.DetailNumber = DetailRow.DetailNumber; AARow.AnalysisTypeCode = AttrRow.AnalysisTypeCode; AARow.AccountCode = DetailRow.AccountCode; FMainDS.AApAnalAttrib.Rows.Add(AARow); } } FMainDS.AApAnalAttrib.DefaultView.RowFilter = AccountCodeRowFilter; FMainDS.AApAnalAttrib.DefaultView.Sort = AApAnalAttribTable.GetAnalysisTypeCodeDBName(); grdAnalAttributes.DataSource = null; grdAnalAttributes.DataSource = new DevAge.ComponentModel.BoundDataView(FMainDS.AApAnalAttrib.DefaultView); UpdateAttributeLabel(DetailRow); if (grdAnalAttributes.Rows.Count > 2) { grdAnalAttributes.Enabled = true; grdAnalAttributes.SelectRowWithoutFocus(1); AnalysisAttributesGrid_RowSelected(null, null); } else { grdAnalAttributes.Enabled = false; } }
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); } }
/// <summary> /// グリッドにリストを生成する /// </summary> private void ListCreate() { // グリッドクリア this.GridClear(); // BGWC壁紙フォルダが存在するときのみリスト作成 if (Directory.Exists(this.txtWallpaperFolder.Text)) { // BGWC壁紙フォルダ以下にあるファイルを取得し配列に格納 string[] strAllFiles = Directory.GetFiles(this.txtWallpaperFolder.Text, "*", SearchOption.AllDirectories); // 壁紙に関するファイルだけ抽出 List <string> lstGraphicFile = new List <string>(); // 壁紙用ファイルリスト初期化 lstGraphicFile.Capacity = strAllFiles.Length; foreach (string strFile in strAllFiles) { if (this.CheckFileExt(Path.GetExtension(strFile))) { lstGraphicFile.Add(strFile); } } // リストを作成 // SourceGrid用イベント初期化 CellDoubleClickEvent doubleclickController = new CellDoubleClickEvent(); FileNameCellClickEvent filenameClickController = new FileNameCellClickEvent(); //FileNameEditStartEvent filenameeditstartController = new FileNameEditStartEvent(); WallpaperColorCellClickEvent wallpaperColorClickController = new WallpaperColorCellClickEvent(); KeyDownEvent keydownController = new KeyDownEvent(); // 壁紙位置リスト生成 SourceGrid.Cells.Editors.ComboBox cbEditor = new SourceGrid.Cells.Editors.ComboBox(typeof(string)); cbEditor.StandardValues = new string[] { "", MainProgram.conWallpaperPos_Ori, MainProgram.conWallpaperPos_Arr, MainProgram.conWallpaperPos_Fit }; cbEditor.EditableMode = SourceGrid.EditableMode.Focus | SourceGrid.EditableMode.SingleClick | SourceGrid.EditableMode.AnyKey; cbEditor.Control.DropDownStyle = ComboBoxStyle.DropDownList; // 検索用IndexList初期化 _lstKeyIndexList = new List <string>(); _lstKeyIndexList.Capacity = 1000; // ヘッダの分を追加しておく _lstKeyIndexList.Add(""); // 壁紙用ファイルリストから1つずつとりだす foreach (string strFile in lstGraphicFile) { // 新規行番号を取得 int i = griList.RowsCount; // 新規行を追加 griList.Rows.Insert(i); // ファイル名用セル生成 griList[i, (int)MainProgram.enuGrid.FILENAME] = new SourceGrid.Cells.Cell(strFile.Replace(this.txtWallpaperFolder.Text + "\\", ""), typeof(string)); griList[i, (int)MainProgram.enuGrid.FILENAME].Editor.EditableMode = SourceGrid.EditableMode.None; griList[i, (int)MainProgram.enuGrid.FILENAME].AddController(doubleclickController); griList[i, (int)MainProgram.enuGrid.FILENAME].AddController(filenameClickController); //griList[i, (int)MainProgram.enuGrid.FILENAME].AddController(filenameeditstartController); griList[i, (int)MainProgram.enuGrid.FILENAME].AddController(keydownController); // 検索用Indexリストに追加 _lstKeyIndexList.Add(strFile.Replace(WallpaperFolder + "\\", "")); // 追加するファイルパス格納 string strAddFilePath = txtWallpaperFolder.Text + "\\" + griList[i, (int)MainProgram.enuGrid.FILENAME].Value; // 壁紙サイズ用セル生成 //if (this.CheckFileExt((Path.GetExtension(strFile)))){ griList[i, (int)MainProgram.enuGrid.WALLPAPERSIZE] = new SourceGrid.Cells.Cell(MainFunc.GetWallpaperSize(strAddFilePath)); //} // 壁紙位置用セル生成 griList[i, (int)MainProgram.enuGrid.VIEWPOS] = new SourceGrid.Cells.Cell("", cbEditor); griList[i, (int)MainProgram.enuGrid.VIEWPOS].View = SourceGrid.Cells.Views.ComboBox.Default; // 壁紙色用セル生成 griList[i, (int)MainProgram.enuGrid.COLOR] = new SourceGrid.Cells.Cell("None", typeof(string)); griList[i, (int)MainProgram.enuGrid.COLOR].AddController(wallpaperColorClickController); griList[i, (int)MainProgram.enuGrid.COLOR].Editor.EditableMode = SourceGrid.EditableMode.None; // 壁紙色(RGB)用セル生成 griList[i, (int)MainProgram.enuGrid.RGBCOLOR] = new SourceGrid.Cells.Cell("", typeof(string)); } // 検索用Indexリストのキャパシティを調整 _lstKeyIndexList.TrimExcess(); // 個別壁紙表示設定が存在する場合(ViewSettingファイルが存在) if (File.Exists(MainProgram.ApplicationPath + "\\" + MainProgram.conViewSetFileName)) { // 個別壁紙表示設定を取得 (DLL) ViewSetting vset = new ViewSetting(); // ViewSettingファイルからロード vset.ReadViewSetting(MainProgram.ApplicationPath + "\\" + MainProgram.conViewSetFileName); // ViewSettingListから1つずつ取り出す foreach (GVWI gvwi in vset.List) { // BGWCKeyをもつIndexを検索 int idx = GetKeyIndex(gvwi.Key); // 見つかったとき if (idx > 0) { // ヘッダの分プラス //idx++; // 壁紙位置を更新 griList[idx, (int)MainProgram.enuGrid.VIEWPOS] = new SourceGrid.Cells.Cell(gvwi.ViewPos, cbEditor); griList[idx, (int)MainProgram.enuGrid.VIEWPOS].View = SourceGrid.Cells.Views.ComboBox.Default; if (gvwi.Color != "") { // 壁紙色を更新 griList[idx, (int)MainProgram.enuGrid.RGBCOLOR] = new SourceGrid.Cells.Cell(gvwi.Color, typeof(string)); string[] strRGB = gvwi.Color.Split(' '); SourceGrid.Cells.Views.Cell cview = new SourceGrid.Cells.Views.Cell(); cview.BackColor = Color.FromArgb(int.Parse(strRGB[0]), int.Parse(strRGB[1]), int.Parse(strRGB[2])); griList[idx, (int)MainProgram.enuGrid.COLOR].View = cview; griList[idx, (int)MainProgram.enuGrid.COLOR].Value = ""; } } } } // 現在の壁紙を選択状態にする ListWallpaperSelected(GetWallpaperKey(NowWallpaper)); } }
protected override void OnLoad(EventArgs e) { base.OnLoad(e); grid.Redim(62, 3); SourceGrid.Cells.Views.Cell titleModel = new SourceGrid.Cells.Views.Cell(); titleModel.BackColor = Color.SteelBlue; titleModel.ForeColor = Color.White; titleModel.TextAlignment = DevAge.Drawing.ContentAlignment.MiddleCenter; SourceGrid.Cells.Views.Cell captionModel = new SourceGrid.Cells.Views.Cell(); captionModel.BackColor = grid.BackColor; int currentRow = 0; #region Base Types grid[currentRow, 0] = new SourceGrid.Cells.Cell("Base Types"); grid[currentRow, 0].View = titleModel; grid[currentRow, 0].ColumnSpan = 3; currentRow++; //string grid[currentRow, 0] = new SourceGrid.Cells.Cell("String"); grid[currentRow, 0].View = captionModel; grid[currentRow, 1] = new SourceGrid.Cells.Cell("String Value", typeof(string)); currentRow++; //double grid[currentRow, 0] = new SourceGrid.Cells.Cell("Double"); grid[currentRow, 0].View = captionModel; grid[currentRow, 1] = new SourceGrid.Cells.Cell(1.5, typeof(double)); currentRow++; //int grid[currentRow, 0] = new SourceGrid.Cells.Cell("Int"); grid[currentRow, 0].View = captionModel; grid[currentRow, 1] = new SourceGrid.Cells.Cell(5, typeof(int)); currentRow++; //DateTime grid[currentRow, 0] = new SourceGrid.Cells.Cell("DateTime"); grid[currentRow, 0].View = captionModel; grid[currentRow, 1] = new SourceGrid.Cells.Cell(DateTime.Now, typeof(DateTime)); currentRow++; //Boolean grid[currentRow, 0] = new SourceGrid.Cells.Cell("Boolean"); grid[currentRow, 0].View = captionModel; grid[currentRow, 1] = new SourceGrid.Cells.Cell(true, typeof(Boolean)); currentRow++; #endregion #region Complex Types grid[currentRow, 0] = new SourceGrid.Cells.Cell("Complex Types"); grid[currentRow, 0].View = titleModel; grid[currentRow, 0].ColumnSpan = 3; currentRow++; //Font grid[currentRow, 0] = new SourceGrid.Cells.Cell("Font"); grid[currentRow, 0].View = captionModel; grid[currentRow, 1] = new SourceGrid.Cells.Cell(this.Font, typeof(Font)); currentRow++; //Cursor grid[currentRow, 0] = new SourceGrid.Cells.Cell("Cursor"); grid[currentRow, 0].View = captionModel; grid[currentRow, 1] = new SourceGrid.Cells.Cell(Cursors.Arrow, typeof(Cursor)); currentRow++; //Point grid[currentRow, 0] = new SourceGrid.Cells.Cell("Point"); grid[currentRow, 0].View = captionModel; grid[currentRow, 1] = new SourceGrid.Cells.Cell(new Point(2, 3), typeof(Point)); currentRow++; //Rectangle grid[currentRow, 0] = new SourceGrid.Cells.Cell("Rectangle"); grid[currentRow, 0].View = captionModel; grid[currentRow, 1] = new SourceGrid.Cells.Cell(new Rectangle(100, 100, 200, 200), typeof(Rectangle)); currentRow++; //Image grid[currentRow, 0] = new SourceGrid.Cells.Cell("Image"); grid[currentRow, 0].View = captionModel; grid[currentRow, 1] = new SourceGrid.Cells.Image(Properties.Resources.CalcioSmall); currentRow++; //Enum AnchorStyle grid[currentRow, 0] = new SourceGrid.Cells.Cell("AnchorStyle"); grid[currentRow, 0].View = captionModel; grid[currentRow, 1] = new SourceGrid.Cells.Cell(AnchorStyles.Bottom, typeof(AnchorStyles)); currentRow++; //Enum grid[currentRow, 0] = new SourceGrid.Cells.Cell("Enum"); grid[currentRow, 0].View = captionModel; grid[currentRow, 1] = new SourceGrid.Cells.Cell(System.Windows.Forms.BorderStyle.Fixed3D, typeof(System.Windows.Forms.BorderStyle)); currentRow++; //String[] grid[currentRow, 0] = new SourceGrid.Cells.Cell("String Array"); grid[currentRow, 0].View = captionModel; string[] strArray = new string[] { "Value 1", "Value 2" }; grid[currentRow, 1] = new SourceGrid.Cells.Cell(strArray, typeof(string[])); currentRow++; //Double[] grid[currentRow, 0] = new SourceGrid.Cells.Cell("Double Array"); grid[currentRow, 0].View = captionModel; double[] dblArray = new double[] { 1, 0.5, 0.1 }; grid[currentRow, 1] = new SourceGrid.Cells.Cell(dblArray, typeof(double[])); currentRow++; #endregion #region Special Editors grid[currentRow, 0] = new SourceGrid.Cells.Cell("Special Editors"); grid[currentRow, 0].View = titleModel; grid[currentRow, 0].ColumnSpan = 3; currentRow++; //Time grid[currentRow, 0] = new SourceGrid.Cells.Cell("Time"); grid[currentRow, 0].View = captionModel; grid[currentRow, 1] = new SourceGrid.Cells.Cell(DateTime.Now); grid[currentRow, 1].Editor = new SourceGrid.Cells.Editors.TimePicker(); currentRow++; //Double Chars Validation grid[currentRow, 0] = new SourceGrid.Cells.Cell("Double Chars Validation"); grid[currentRow, 0].View = captionModel; SourceGrid.Cells.Editors.TextBoxNumeric numericEditor = new SourceGrid.Cells.Editors.TextBoxNumeric(typeof(double)); numericEditor.KeyPress += delegate(object sender, KeyPressEventArgs keyArgs) { bool isValid = char.IsNumber(keyArgs.KeyChar) || keyArgs.KeyChar == System.Globalization.CultureInfo.CurrentCulture.NumberFormat.NumberDecimalSeparator[0]; keyArgs.Handled = !isValid; }; grid[currentRow, 1] = new SourceGrid.Cells.Cell(0.5); grid[currentRow, 1].Editor = numericEditor; currentRow++; //String Chars (ABC) grid[currentRow, 0] = new SourceGrid.Cells.Cell("Chars Validation(only ABC)"); grid[currentRow, 0].View = captionModel; SourceGrid.Cells.Editors.TextBox stringEditor = new SourceGrid.Cells.Editors.TextBox(typeof(string)); stringEditor.KeyPress += delegate(object sender, KeyPressEventArgs keyArgs) { keyArgs.KeyChar = char.ToUpper(keyArgs.KeyChar); bool isValid = keyArgs.KeyChar == 'A' || keyArgs.KeyChar == 'B' || keyArgs.KeyChar == 'C'; keyArgs.Handled = !isValid; }; grid[currentRow, 1] = new SourceGrid.Cells.Cell("AABB"); grid[currentRow, 1].Editor = stringEditor; currentRow++; //String Validating grid[currentRow, 0] = new SourceGrid.Cells.Cell("String validating(min 6 chars)"); grid[currentRow, 0].View = captionModel; SourceGrid.Cells.Editors.TextBox stringEditorValidating = new SourceGrid.Cells.Editors.TextBox(typeof(string)); stringEditorValidating.Control.Validating += delegate(object sender, CancelEventArgs cancelEvent) { string val = ((TextBox)sender).Text; if (val == null || val.Length < 6) { cancelEvent.Cancel = true; } }; grid[currentRow, 1] = new SourceGrid.Cells.Cell("test string"); grid[currentRow, 1].Editor = stringEditorValidating; currentRow++; //Int 0-100 or null grid[currentRow, 0] = new SourceGrid.Cells.Cell("Int 0-100 or null"); grid[currentRow, 0].View = captionModel; SourceGrid.Cells.Editors.TextBoxNumeric numericEditor0_100 = new SourceGrid.Cells.Editors.TextBoxNumeric(typeof(int)); numericEditor0_100.MinimumValue = 0; numericEditor0_100.MaximumValue = 100; numericEditor0_100.AllowNull = true; grid[currentRow, 1] = new SourceGrid.Cells.Cell(7); grid[currentRow, 1].Editor = numericEditor0_100; currentRow++; //Double Custom Conversion grid[currentRow, 0] = new SourceGrid.Cells.Cell("Dbl custom conversion"); grid[currentRow, 0].View = captionModel; SourceGrid.Cells.Editors.TextBox dblCustomConversion = new SourceGrid.Cells.Editors.TextBox(typeof(double)); dblCustomConversion.ConvertingObjectToValue += delegate(object sender, DevAge.ComponentModel.ConvertingObjectEventArgs conv) { if (conv.Value is string) { //Here you can add any custom code double val; if (double.TryParse((string)conv.Value, out val)) { conv.Value = val; conv.ConvertingStatus = DevAge.ComponentModel.ConvertingStatus.Completed; } } }; grid[currentRow, 1] = new SourceGrid.Cells.Cell(73.839); grid[currentRow, 1].Editor = dblCustomConversion; currentRow++; //Enum Custom Display grid[currentRow, 0] = new SourceGrid.Cells.Cell("Enum Custom Display"); grid[currentRow, 0].View = captionModel; SourceGrid.Cells.Editors.ComboBox keysCombo = new SourceGrid.Cells.Editors.ComboBox(typeof(Keys)); keysCombo.Control.FormattingEnabled = true; keysCombo.ConvertingValueToDisplayString += delegate(object sender, DevAge.ComponentModel.ConvertingObjectEventArgs convArgs) { if (convArgs.Value is Keys) { convArgs.Value = (int)((Keys)convArgs.Value) + " - " + convArgs.Value.ToString(); } }; grid[currentRow, 1] = new SourceGrid.Cells.Cell(Keys.Enter); grid[currentRow, 1].Editor = keysCombo; currentRow++; string[] arraySample = new string[] { "Value 1", "Value 2", "Value 3" }; //ComboBox 1 grid[currentRow, 0] = new SourceGrid.Cells.Cell("ComboBox String"); grid[currentRow, 0].View = captionModel; SourceGrid.Cells.Editors.ComboBox comboStandard = new SourceGrid.Cells.Editors.ComboBox(typeof(string), arraySample, false); comboStandard.Control.MaxLength = 10; grid[currentRow, 1] = new SourceGrid.Cells.Cell(arraySample[0], comboStandard); currentRow++; //ComboBox exclusive grid[currentRow, 0] = new SourceGrid.Cells.Cell("ComboBox String Exclusive"); grid[currentRow, 0].View = captionModel; SourceGrid.Cells.Editors.ComboBox comboExclusive = new SourceGrid.Cells.Editors.ComboBox(typeof(string), arraySample, true); grid[currentRow, 1] = new SourceGrid.Cells.Cell(arraySample[0], comboExclusive); currentRow++; //ComboBox AutoComplete grid[currentRow, 0] = new SourceGrid.Cells.Cell("ComboBox AutoComplete"); grid[currentRow, 0].View = captionModel; SourceGrid.Cells.Editors.ComboBox comboAutoComplete = new SourceGrid.Cells.Editors.ComboBox(typeof(string), new string[] { "AAA", "ABC", "AZA", "BAA", "ZAA" }, true); comboAutoComplete.Control.AutoCompleteSource = AutoCompleteSource.ListItems; comboAutoComplete.Control.AutoCompleteMode = AutoCompleteMode.Append; grid[currentRow, 1] = new SourceGrid.Cells.Cell("AAA", comboAutoComplete); currentRow++; //ComboBox DropDownList grid[currentRow, 0] = new SourceGrid.Cells.Cell("ComboBox DropDownList"); grid[currentRow, 0].View = captionModel; SourceGrid.Cells.Editors.ComboBox comboNoText = new SourceGrid.Cells.Editors.ComboBox(typeof(string), arraySample, true); grid[currentRow, 1] = new SourceGrid.Cells.Cell(arraySample[0]); grid[currentRow, 1].Editor = comboNoText; comboNoText.Control.DropDownStyle = ComboBoxStyle.DropDownList; currentRow++; //ComboBox DateTime Editable grid[currentRow, 0] = new SourceGrid.Cells.Cell("ComboBox DateTime"); grid[currentRow, 0].View = captionModel; DateTime[] arrayDt = new DateTime[] { new DateTime(1981, 10, 6), new DateTime(1991, 10, 6), new DateTime(2001, 10, 6) }; SourceGrid.Cells.Editors.ComboBox comboDateTime = new SourceGrid.Cells.Editors.ComboBox(typeof(DateTime), arrayDt, false); grid[currentRow, 1] = new SourceGrid.Cells.Cell(arrayDt[0], comboDateTime); currentRow++; //ComboBox Custom Display (create a datamodel that has a custom display string) grid[currentRow, 0] = new SourceGrid.Cells.Cell("ComboBox Custom Display"); grid[currentRow, 0].View = captionModel; int[] arrInt = new int[] { 0, 1, 2, 3, 4 }; string[] arrStr = new string[] { "0 - Zero", "1 - One", "2 - Two", "3 - Three", "4- Four" }; SourceGrid.Cells.Editors.ComboBox editorComboCustomDisplay = new SourceGrid.Cells.Editors.ComboBox(typeof(int), arrInt, true); editorComboCustomDisplay.Control.FormattingEnabled = true; DevAge.ComponentModel.Validator.ValueMapping comboMapping = new DevAge.ComponentModel.Validator.ValueMapping(); comboMapping.DisplayStringList = arrStr; comboMapping.ValueList = arrInt; comboMapping.SpecialList = arrStr; comboMapping.SpecialType = typeof(string); comboMapping.BindValidator(editorComboCustomDisplay); grid[currentRow, 1] = new SourceGrid.Cells.Cell(0); grid[currentRow, 1].Editor = editorComboCustomDisplay; SourceGrid.Cells.Cell l_CellComboRealValue = new SourceGrid.Cells.Cell(grid[currentRow, 1].Value); l_CellComboRealValue.View = captionModel; SourceGrid.Cells.Controllers.BindProperty l_ComboBindProperty = new SourceGrid.Cells.Controllers.BindProperty(typeof(SourceGrid.Cells.Cell).GetProperty("Value"), l_CellComboRealValue); grid[currentRow, 1].AddController(l_ComboBindProperty); grid[currentRow, 2] = l_CellComboRealValue; currentRow++; //ComboBox with inline View grid[currentRow, 0] = new SourceGrid.Cells.Cell("ComboBox Inline View"); grid[currentRow, 0].View = captionModel; SourceGrid.Cells.Editors.ComboBox cbInline = new SourceGrid.Cells.Editors.ComboBox(typeof(string), arraySample, false); cbInline.EditableMode = SourceGrid.EditableMode.Default | SourceGrid.EditableMode.Focus; grid[currentRow, 1] = new SourceGrid.Cells.Cell(arraySample[0], cbInline); grid[currentRow, 1].View = SourceGrid.Cells.Views.ComboBox.Default; currentRow++; //Numeric Up Down Editor grid[currentRow, 0] = new SourceGrid.Cells.Cell("NumericUpDown"); grid[currentRow, 0].View = captionModel; grid[currentRow, 1] = new SourceGrid.Cells.Cell(0); SourceGrid.Cells.Editors.NumericUpDown l_NumericUpDownEditor = new SourceGrid.Cells.Editors.NumericUpDown(typeof(int), 50, -50, 1); grid[currentRow, 1].Editor = l_NumericUpDownEditor; currentRow++; //Multiline Textbox grid[currentRow, 0] = new SourceGrid.Cells.Cell("Multiline Textbox"); grid[currentRow, 0].View = captionModel; grid[currentRow, 0].ColumnSpan = 1; grid[currentRow, 0].RowSpan = 2; grid[currentRow, 1] = new SourceGrid.Cells.Cell("Hello\r\nWorld"); SourceGrid.Cells.Editors.TextBox l_MultilineEditor = new SourceGrid.Cells.Editors.TextBox(typeof(string)); l_MultilineEditor.Control.Multiline = true; grid[currentRow, 1].Editor = l_MultilineEditor; grid[currentRow, 1].RowSpan = 2; currentRow++; currentRow++; //Boolean (CheckBox) grid[currentRow, 0] = new SourceGrid.Cells.Cell("Boolean (CheckBox)"); grid[currentRow, 0].View = captionModel; grid[currentRow, 1] = new SourceGrid.Cells.CheckBox(null, true); grid[currentRow, 1].FindController <SourceGrid.Cells.Controllers.CheckBox>().CheckedChanged += InvertDisabledCheckBox(currentRow); SourceGrid.Cells.CheckBox l_DisabledCheckBox = new SourceGrid.Cells.CheckBox("Disabled Checkbox", true); l_DisabledCheckBox.Editor.EnableEdit = false; grid[currentRow, 2] = l_DisabledCheckBox; currentRow++; //DateTime with DateTimePicker Editor grid[currentRow, 0] = new SourceGrid.Cells.Cell("DateTimePicker"); grid[currentRow, 0].View = captionModel; SourceGrid.Cells.Editors.DateTimePicker editorDtPicker = new SourceGrid.Cells.Editors.DateTimePicker(); grid[currentRow, 1] = new SourceGrid.Cells.Cell(DateTime.Today); grid[currentRow, 1].Editor = editorDtPicker; currentRow++; //DateTime with DateTimePicker nullable Editor grid[currentRow, 0] = new SourceGrid.Cells.Cell("DateTimePicker nullable"); grid[currentRow, 0].View = captionModel; SourceGrid.Cells.Editors.DateTimePicker editorDtPickerNull = new SourceGrid.Cells.Editors.DateTimePicker(); editorDtPickerNull.AllowNull = true; grid[currentRow, 1] = new SourceGrid.Cells.Cell(null); grid[currentRow, 1].Editor = editorDtPickerNull; currentRow++; //File editor grid[currentRow, 0] = new SourceGrid.Cells.Cell("File editor"); grid[currentRow, 0].View = captionModel; grid[currentRow, 1] = new SourceGrid.Cells.Cell("c:\\windows\\System32\\user32.dll", new EditorFileDialog()); currentRow++; // Richtext box grid[currentRow, 0] = new SourceGrid.Cells.Cell("RichTextBox editor"); grid[currentRow, 0].View = captionModel; string rtf = "{\\rtf1\\ansi\\ansicpg1252\\deff0\\deflang1033{\\fonttbl{\\f0\\fnil\\fcharset0" + "Microsoft Sans Serif;}}\r\n\\viewkind4\\uc1\\pard\\f0\\fs17 Only a \\b " + "Test\\b0.\\par\r\n}\r\n"; var richTextBox = new SourceGrid.Cells.RichTextBox(new RichText(rtf)); grid[currentRow, 1] = richTextBox; currentRow++; #endregion #region Special Cells grid[currentRow, 0] = new SourceGrid.Cells.Cell("Special Cells"); grid[currentRow, 0].View = titleModel; grid[currentRow, 0].ColumnSpan = 3; currentRow++; //Cell Button grid[currentRow, 0] = new SourceGrid.Cells.Cell("Cell Button"); grid[currentRow, 0].View = captionModel; grid[currentRow, 1] = new SourceGrid.Cells.Button("CellButton"); grid[currentRow, 1].Image = Properties.Resources.FACE02.ToBitmap(); SourceGrid.Cells.Controllers.Button buttonClickEvent = new SourceGrid.Cells.Controllers.Button(); buttonClickEvent.Executed += new EventHandler(CellButton_Click); grid[currentRow, 1].Controller.AddController(buttonClickEvent); currentRow++; //Cell Link grid[currentRow, 0] = new SourceGrid.Cells.Cell("Cell Link"); grid[currentRow, 0].View = captionModel; grid[currentRow, 1] = new SourceGrid.Cells.Link("CellLink"); SourceGrid.Cells.Controllers.Button linkClickEvent = new SourceGrid.Cells.Controllers.Button(); linkClickEvent.Executed += new EventHandler(CellLink_Click); grid[currentRow, 1].Controller.AddController(linkClickEvent); currentRow++; //Custom draw cell grid[currentRow, 0] = new SourceGrid.Cells.Cell("Custom draw cell"); grid[currentRow, 0].View = captionModel; grid[currentRow, 1] = new SourceGrid.Cells.Cell("CustomView"); grid[currentRow, 1].View = new RoundView(); currentRow++; //Control Cell grid[currentRow, 0] = new SourceGrid.Cells.Cell("Control Cell"); grid[currentRow, 0].View = captionModel; grid[currentRow, 1] = new SourceGrid.Cells.Cell("control cell"); ProgressBar progressBar = new ProgressBar(); progressBar.Value = 50; grid.LinkedControls.Add(new SourceGrid.LinkedControlValue(progressBar, new SourceGrid.Position(currentRow, 1))); currentRow++; //Custom Border Cell grid[currentRow, 0] = new SourceGrid.Cells.Cell("Custom Border"); grid[currentRow, 0].View = captionModel; SourceGrid.Cells.Views.Cell viewCustomBorder = new SourceGrid.Cells.Views.Cell(); viewCustomBorder.Border = new DevAge.Drawing.RectangleBorder(new DevAge.Drawing.BorderLine(Color.Red, 1), new DevAge.Drawing.BorderLine(Color.Blue, 1), new DevAge.Drawing.BorderLine(Color.Violet, 1), new DevAge.Drawing.BorderLine(Color.Green, 1)); grid[currentRow, 1] = new SourceGrid.Cells.Cell("Custom Border"); grid[currentRow, 1].View = viewCustomBorder; currentRow++; #endregion #region Custom Formatting grid[currentRow, 0] = new SourceGrid.Cells.Cell("Custom Formatting"); grid[currentRow, 0].View = titleModel; grid[currentRow, 0].ColumnSpan = 3; currentRow++; //Format grid[currentRow, 0] = new SourceGrid.Cells.Cell("Default Format"); grid[currentRow, 0].View = captionModel; grid[currentRow, 1] = new SourceGrid.Cells.Cell(88.5246); SourceGrid.Cells.Editors.TextBox editorCustom = new SourceGrid.Cells.Editors.TextBox(typeof(double)); editorCustom.TypeConverter = new DevAge.ComponentModel.Converter.CurrencyTypeConverter(typeof(double)); DevAge.ComponentModel.Converter.NumberTypeConverter numberFormatCustom = new DevAge.ComponentModel.Converter.NumberTypeConverter(typeof(double)); editorCustom.TypeConverter = numberFormatCustom; grid[currentRow, 1].Editor = editorCustom; currentRow++; //Percent Editor grid[currentRow, 0] = new SourceGrid.Cells.Cell("Percent Format"); grid[currentRow, 0].View = captionModel; grid[currentRow, 1] = new SourceGrid.Cells.Cell(88.5246); SourceGrid.Cells.Editors.TextBox l_PercentEditor = new SourceGrid.Cells.Editors.TextBox(typeof(double)); l_PercentEditor.TypeConverter = new DevAge.ComponentModel.Converter.PercentTypeConverter(typeof(double)); grid[currentRow, 1].Editor = l_PercentEditor; currentRow++; //Currency Editor grid[currentRow, 0] = new SourceGrid.Cells.Cell("Currency Format"); grid[currentRow, 0].View = captionModel; grid[currentRow, 1] = new SourceGrid.Cells.Cell(88.5246M); SourceGrid.Cells.Editors.TextBox l_CurrencyEditor = new SourceGrid.Cells.Editors.TextBox(typeof(decimal)); l_CurrencyEditor.TypeConverter = new DevAge.ComponentModel.Converter.CurrencyTypeConverter(typeof(decimal)); grid[currentRow, 1].Editor = l_CurrencyEditor; currentRow++; //Format (#.00) grid[currentRow, 0] = new SourceGrid.Cells.Cell("Format #.00"); grid[currentRow, 0].View = captionModel; grid[currentRow, 1] = new SourceGrid.Cells.Cell(88.5246); editorCustom = new SourceGrid.Cells.Editors.TextBox(typeof(double)); numberFormatCustom = new DevAge.ComponentModel.Converter.NumberTypeConverter(typeof(double)); numberFormatCustom.Format = "#.00"; editorCustom.TypeConverter = numberFormatCustom; grid[currentRow, 1].Editor = editorCustom; currentRow++; //Format ("0000.0000") grid[currentRow, 0] = new SourceGrid.Cells.Cell("Format 0000.0000"); grid[currentRow, 0].View = captionModel; grid[currentRow, 1] = new SourceGrid.Cells.Cell(88.5246); editorCustom = new SourceGrid.Cells.Editors.TextBox(typeof(double)); numberFormatCustom = new DevAge.ComponentModel.Converter.NumberTypeConverter(typeof(double)); numberFormatCustom.Format = "0000.0000"; editorCustom.TypeConverter = numberFormatCustom; grid[currentRow, 1].Editor = editorCustom; currentRow++; //Format ("Scientific (exponential)") grid[currentRow, 0] = new SourceGrid.Cells.Cell("Format Scientific"); grid[currentRow, 0].View = captionModel; grid[currentRow, 1] = new SourceGrid.Cells.Cell(0.0006); SourceGrid.Cells.Editors.TextBoxNumeric editorExponential = new SourceGrid.Cells.Editors.TextBoxNumeric(typeof(double)); DevAge.ComponentModel.Converter.NumberTypeConverter exponentialConverter = new DevAge.ComponentModel.Converter.NumberTypeConverter(typeof(double), "e"); exponentialConverter.NumberStyles = System.Globalization.NumberStyles.Float | System.Globalization.NumberStyles.AllowExponent; editorExponential.TypeConverter = exponentialConverter; grid[currentRow, 1].Editor = editorExponential; currentRow++; //DateTime 2 (using custom formatting) string dtFormat2 = "yyyy MM dd"; grid[currentRow, 0] = new SourceGrid.Cells.Cell("Date(" + dtFormat2 + ")"); grid[currentRow, 0].View = captionModel; string[] dtParseFormats = new string[] { dtFormat2 }; System.Globalization.DateTimeStyles dtStyles = System.Globalization.DateTimeStyles.AllowInnerWhite | System.Globalization.DateTimeStyles.AllowLeadingWhite | System.Globalization.DateTimeStyles.AllowTrailingWhite | System.Globalization.DateTimeStyles.AllowWhiteSpaces; TypeConverter dtConverter = new DevAge.ComponentModel.Converter.DateTimeTypeConverter(dtFormat2, dtParseFormats, dtStyles); SourceGrid.Cells.Editors.TextBoxUITypeEditor editorDt2 = new SourceGrid.Cells.Editors.TextBoxUITypeEditor(typeof(DateTime)); editorDt2.TypeConverter = dtConverter; grid[currentRow, 1] = new SourceGrid.Cells.Cell(DateTime.Today); grid[currentRow, 1].Editor = editorDt2; currentRow++; //Text Ellipses grid[currentRow, 0] = new SourceGrid.Cells.Cell("Text Ellipses"); grid[currentRow, 0].View = captionModel; grid[currentRow, 1] = new SourceGrid.Cells.Cell("This text is very very long and shows how to trim and add ellipses", typeof(string)); SourceGrid.Cells.Views.Cell ellipsesView = new SourceGrid.Cells.Views.Cell(); ellipsesView.TrimmingMode = SourceGrid.TrimmingMode.Word; grid[currentRow, 1].View = ellipsesView; currentRow++; #endregion #region Image And Text Properties grid[currentRow, 0] = new SourceGrid.Cells.Cell("Image And Text Properties"); grid[currentRow, 0].View = titleModel; grid[currentRow, 0].ColumnSpan = 3; currentRow++; //Cell Image SourceGrid.Cells.Cell cellImage1 = new SourceGrid.Cells.Cell("Single Image"); SourceGrid.Cells.Views.Cell viewImage = new SourceGrid.Cells.Views.Cell(captionModel); cellImage1.View = viewImage; grid[currentRow, 2] = cellImage1; cellImage1.RowSpan = 4; cellImage1.Image = Properties.Resources.FACE02.ToBitmap(); grid[currentRow, 0] = new SourceGrid.Cells.Cell("Image Alignment"); grid[currentRow, 0].View = captionModel; grid[currentRow, 1] = new SourceGrid.Cells.Cell(viewImage.ImageAlignment, typeof(DevAge.Drawing.ContentAlignment)); grid[currentRow, 1].AddController(new SourceGrid.Cells.Controllers.BindProperty(typeof(SourceGrid.Cells.Views.Cell).GetProperty("ImageAlignment"), viewImage)); currentRow++; grid[currentRow, 0] = new SourceGrid.Cells.Cell("Stretch Image"); grid[currentRow, 0].View = captionModel; grid[currentRow, 1] = new SourceGrid.Cells.Cell(viewImage.ImageStretch, typeof(bool)); grid[currentRow, 1].AddController(new SourceGrid.Cells.Controllers.BindProperty(typeof(SourceGrid.Cells.Views.Cell).GetProperty("ImageStretch"), viewImage)); currentRow++; grid[currentRow, 0] = new SourceGrid.Cells.Cell("Text Alignment"); grid[currentRow, 0].View = captionModel; grid[currentRow, 1] = new SourceGrid.Cells.Cell(viewImage.TextAlignment, typeof(DevAge.Drawing.ContentAlignment)); grid[currentRow, 1].AddController(new SourceGrid.Cells.Controllers.BindProperty(typeof(SourceGrid.Cells.Views.Cell).GetProperty("TextAlignment"), viewImage)); currentRow++; grid[currentRow, 0] = new SourceGrid.Cells.Cell("DrawMode"); grid[currentRow, 0].View = captionModel; grid[currentRow, 1] = new SourceGrid.Cells.Cell(viewImage.ElementsDrawMode, typeof(DevAge.Drawing.ElementsDrawMode)); grid[currentRow, 1].AddController(new SourceGrid.Cells.Controllers.BindProperty(typeof(SourceGrid.Cells.Views.Cell).GetProperty("ElementsDrawMode"), viewImage)); currentRow++; // Cell VisualModelMultiImages grid[currentRow, 1] = new SourceGrid.Cells.Cell("Multi Images"); SourceGrid.Cells.Views.MultiImages modelMultiImages = new SourceGrid.Cells.Views.MultiImages(); modelMultiImages.SubImages.Add(new DevAge.Drawing.VisualElements.Image(Properties.Resources.FACE00.ToBitmap())); modelMultiImages.SubImages.Add(new DevAge.Drawing.VisualElements.Image(Properties.Resources.FACE01.ToBitmap())); modelMultiImages.SubImages.Add(new DevAge.Drawing.VisualElements.Image(Properties.Resources.FACE02.ToBitmap())); modelMultiImages.SubImages.Add(new DevAge.Drawing.VisualElements.Image(Properties.Resources.FACE04.ToBitmap())); modelMultiImages.SubImages[0].AnchorArea = new DevAge.Drawing.AnchorArea(DevAge.Drawing.ContentAlignment.TopLeft, false); modelMultiImages.SubImages[1].AnchorArea = new DevAge.Drawing.AnchorArea(DevAge.Drawing.ContentAlignment.TopRight, false); modelMultiImages.SubImages[2].AnchorArea = new DevAge.Drawing.AnchorArea(DevAge.Drawing.ContentAlignment.BottomLeft, false); modelMultiImages.SubImages[3].AnchorArea = new DevAge.Drawing.AnchorArea(DevAge.Drawing.ContentAlignment.BottomRight, false); modelMultiImages.TextAlignment = DevAge.Drawing.ContentAlignment.MiddleCenter; grid[currentRow, 1].View = modelMultiImages; grid.Rows[currentRow].AutoSizeMode = SourceGrid.AutoSizeMode.MinimumSize; grid.Rows[currentRow].Height = 50; currentRow++; // Cell Rotated Text grid[currentRow, 0] = new SourceGrid.Cells.Cell("Rotated by angle"); grid[currentRow, 0].View = captionModel; grid[currentRow, 1] = new SourceGrid.Cells.Cell("Rotated Text", typeof(string)); SourceGrid.Cells.Views.Cell rotateView = new SourceGrid.Cells.Views.Cell(); rotateView.ElementText = new RotatedText(45); grid[currentRow, 1].View = rotateView; grid.Rows[currentRow].AutoSizeMode = SourceGrid.AutoSizeMode.MinimumSize; grid.Rows[currentRow].Height = 50; currentRow++; // GDI+ Text grid[currentRow, 0] = new SourceGrid.Cells.Cell("GDI+ Text"); grid[currentRow, 0].View = captionModel; grid[currentRow, 1] = new SourceGrid.Cells.Cell("Hello from GDI+", typeof(string)); GDITextView gdiTextView = new GDITextView(); gdiTextView.FormatFlags = StringFormatFlags.DirectionVertical | StringFormatFlags.NoWrap; grid[currentRow, 1].View = gdiTextView; currentRow++; #endregion grid.Columns[0].AutoSizeMode = SourceGrid.AutoSizeMode.MinimumSize | SourceGrid.AutoSizeMode.Default; grid.Columns[1].AutoSizeMode = SourceGrid.AutoSizeMode.MinimumSize | SourceGrid.AutoSizeMode.Default; grid.Columns[2].AutoSizeMode = SourceGrid.AutoSizeMode.MinimumSize | SourceGrid.AutoSizeMode.Default; grid.MinimumWidth = 50; grid.AutoSizeCells(); grid.AutoStretchColumnsToFitWidth = true; grid.Columns.StretchToFit(); }
/// <summary> /// load the transactions into the grid /// </summary> /// <param name="ALedgerNumber"></param> /// <param name="ABatchNumber"></param> /// <param name="AJournalNumber"></param> /// <param name="ACurrencyCode"></param> /// <param name="AFromBatchTab"></param> /// <param name="ABatchStatus"></param> /// <param name="AJournalStatus"></param> /// <returns>True if new GL transactions were loaded, false if transactions had been loaded already.</returns> public bool LoadTransactions(Int32 ALedgerNumber, Int32 ABatchNumber, Int32 AJournalNumber, string ACurrencyCode, bool AFromBatchTab = false, string ABatchStatus = MFinanceConstants.BATCH_UNPOSTED, string AJournalStatus = MFinanceConstants.BATCH_UNPOSTED) { bool DifferentBatchSelected = false; FLoadCompleted = false; FBatchRow = GetBatchRow(); FJournalRow = GetJournalRow(); FIsUnposted = (FBatchRow.BatchStatus == MFinanceConstants.BATCH_UNPOSTED); if (FLedgerNumber == -1) { InitialiseControls(); } //Check if the same batch is selected, so no need to apply filter if ((FLedgerNumber == ALedgerNumber) && (FBatchNumber == ABatchNumber) && (FJournalNumber == AJournalNumber) && (FTransactionCurrency == ACurrencyCode) && (FBatchStatus == ABatchStatus) && (FJournalStatus == AJournalStatus) && (FMainDS.ATransaction.DefaultView.Count > 0)) { //Same as previously selected if (FIsUnposted && (GetSelectedRowIndex() > 0)) { if (AFromBatchTab) { SelectRowInGrid(GetSelectedRowIndex()); } else { GetDetailsFromControls(GetSelectedDetailRow()); } } FLoadCompleted = true; } else { // A new ledger/batch DifferentBatchSelected = true; bool requireControlSetup = (FLedgerNumber == -1) || (FTransactionCurrency != ACurrencyCode); FLedgerNumber = ALedgerNumber; FBatchNumber = ABatchNumber; FJournalNumber = AJournalNumber; FTransactionNumber = -1; FTransactionCurrency = ACurrencyCode; FPreviouslySelectedDetailRow = null; grdDetails.SuspendLayout(); //Empty grids before filling them grdDetails.DataSource = null; grdAnalAttributes.DataSource = null; FBatchStatus = ABatchStatus; FJournalStatus = AJournalStatus; // This sets the main part of the filter but excluding the additional items set by the user GUI // It gets the right sort order SetTransactionDefaultView(); //Load from server if necessary if (FMainDS.ATransaction.DefaultView.Count == 0) { FMainDS.Merge(TRemote.MFinance.GL.WebConnectors.LoadATransactionATransAnalAttrib(ALedgerNumber, ABatchNumber, AJournalNumber)); } // We need to call this because we have not called ShowData(), which would have set it. This differs from the Gift screen. grdDetails.DataSource = new DevAge.ComponentModel.BoundDataView(FMainDS.ATransaction.DefaultView); // Now we set the full filter FFilterAndFindObject.ApplyFilter(); if (grdAnalAttributes.Columns.Count == 1) { grdAnalAttributes.SpecialKeys = GridSpecialKeys.Default | GridSpecialKeys.Tab; FcmbAnalAttribValues = new SourceGrid.Cells.Editors.ComboBox(typeof(string)); FcmbAnalAttribValues.EnableEdit = true; FcmbAnalAttribValues.EditableMode = EditableMode.Focus; grdAnalAttributes.AddTextColumn(Catalog.GetString("Value"), FMainDS.ATransAnalAttrib.Columns[ATransAnalAttribTable.GetAnalysisAttributeValueDBName()], 150, FcmbAnalAttribValues); FcmbAnalAttribValues.Control.SelectedValueChanged += new EventHandler(this.AnalysisAttributeValueChanged); grdAnalAttributes.Columns[0].Width = 99; } FAnalysisAttributesLogic = new TAnalysisAttributes(FLedgerNumber, FBatchNumber, FJournalNumber); FAnalysisAttributesLogic.SetTransAnalAttributeDefaultView(FMainDS, FActiveOnly); FMainDS.ATransAnalAttrib.DefaultView.AllowNew = false; grdAnalAttributes.DataSource = new DevAge.ComponentModel.BoundDataView(FMainDS.ATransAnalAttrib.DefaultView); grdAnalAttributes.SetHeaderTooltip(0, Catalog.GetString("Type")); grdAnalAttributes.SetHeaderTooltip(1, Catalog.GetString("Value")); // if this form is readonly or batch is posted, then we need all account and cost centre codes, because old codes might have been used bool ActiveOnly = (this.Enabled && FIsUnposted); if (requireControlSetup || (FActiveOnly != ActiveOnly)) { FActiveOnly = ActiveOnly; //Load all analysis attribute values if (FCacheDS == null) { FCacheDS = TRemote.MFinance.GL.WebConnectors.LoadAAnalysisAttributes(FLedgerNumber, FActiveOnly); } SetupExtraGridFunctionality(); TFinanceControls.InitialiseAccountList(ref cmbDetailAccountCode, FLedgerNumber, true, false, ActiveOnly, false, ACurrencyCode, true); TFinanceControls.InitialiseCostCentreList(ref cmbDetailCostCentreCode, FLedgerNumber, true, false, ActiveOnly, false); } UpdateTransactionTotals(); grdDetails.ResumeLayout(); FLoadCompleted = true; } ShowData(); SelectRowInGrid(1); ShowDetails(); //Needed because of how currency is handled UpdateChangeableStatus(); UpdateRecordNumberDisplay(); FFilterAndFindObject.SetRecordNumberDisplayProperties(); return DifferentBatchSelected; }
protected override void OnLoad(EventArgs e) { base.OnLoad(e); grid.Redim(62, 3); SourceGrid.Cells.Views.Cell titleModel = new SourceGrid.Cells.Views.Cell(); titleModel.BackColor = Color.SteelBlue; titleModel.ForeColor = Color.White; titleModel.TextAlignment = DevAge.Drawing.ContentAlignment.MiddleCenter; SourceGrid.Cells.Views.Cell captionModel = new SourceGrid.Cells.Views.Cell(); captionModel.BackColor = grid.BackColor; int currentRow = 0; #region Base Types grid[currentRow, 0] = new SourceGrid.Cells.Cell("Base Types"); grid[currentRow, 0].View = titleModel; grid[currentRow, 0].ColumnSpan = 3; currentRow++; //string grid[currentRow, 0] = new SourceGrid.Cells.Cell("String"); grid[currentRow, 0].View = captionModel; grid[currentRow, 1] = new SourceGrid.Cells.Cell("String Value", typeof(string)); currentRow++; //double grid[currentRow, 0] = new SourceGrid.Cells.Cell("Double"); grid[currentRow, 0].View = captionModel; grid[currentRow, 1] = new SourceGrid.Cells.Cell(1.5, typeof(double)); currentRow++; //int grid[currentRow, 0] = new SourceGrid.Cells.Cell("Int"); grid[currentRow, 0].View = captionModel; grid[currentRow, 1] = new SourceGrid.Cells.Cell(5, typeof(int)); currentRow++; //DateTime grid[currentRow, 0] = new SourceGrid.Cells.Cell("DateTime"); grid[currentRow, 0].View = captionModel; grid[currentRow, 1] = new SourceGrid.Cells.Cell(DateTime.Now, typeof(DateTime)); currentRow++; //Boolean grid[currentRow, 0] = new SourceGrid.Cells.Cell("Boolean"); grid[currentRow, 0].View = captionModel; grid[currentRow, 1] = new SourceGrid.Cells.Cell(true, typeof(Boolean)); currentRow++; #endregion #region Complex Types grid[currentRow, 0] = new SourceGrid.Cells.Cell("Complex Types"); grid[currentRow, 0].View = titleModel; grid[currentRow, 0].ColumnSpan = 3; currentRow++; //Font grid[currentRow, 0] = new SourceGrid.Cells.Cell("Font"); grid[currentRow, 0].View = captionModel; grid[currentRow, 1] = new SourceGrid.Cells.Cell(this.Font, typeof(Font)); currentRow++; //Cursor grid[currentRow, 0] = new SourceGrid.Cells.Cell("Cursor"); grid[currentRow, 0].View = captionModel; grid[currentRow, 1] = new SourceGrid.Cells.Cell(Cursors.Arrow, typeof(Cursor)); currentRow++; //Point grid[currentRow, 0] = new SourceGrid.Cells.Cell("Point"); grid[currentRow, 0].View = captionModel; grid[currentRow, 1] = new SourceGrid.Cells.Cell(new Point(2, 3), typeof(Point)); currentRow++; //Rectangle grid[currentRow, 0] = new SourceGrid.Cells.Cell("Rectangle"); grid[currentRow, 0].View = captionModel; grid[currentRow, 1] = new SourceGrid.Cells.Cell(new Rectangle(100, 100, 200, 200), typeof(Rectangle)); currentRow++; //Image grid[currentRow, 0] = new SourceGrid.Cells.Cell("Image"); grid[currentRow, 0].View = captionModel; grid[currentRow, 1] = new SourceGrid.Cells.Image(Properties.Resources.CalcioSmall); currentRow++; //Enum AnchorStyle grid[currentRow, 0] = new SourceGrid.Cells.Cell("AnchorStyle"); grid[currentRow, 0].View = captionModel; grid[currentRow, 1] = new SourceGrid.Cells.Cell(AnchorStyles.Bottom, typeof(AnchorStyles)); currentRow++; //Enum grid[currentRow, 0] = new SourceGrid.Cells.Cell("Enum"); grid[currentRow, 0].View = captionModel; grid[currentRow, 1] = new SourceGrid.Cells.Cell(System.Windows.Forms.BorderStyle.Fixed3D, typeof(System.Windows.Forms.BorderStyle)); currentRow++; //String[] grid[currentRow, 0] = new SourceGrid.Cells.Cell("String Array"); grid[currentRow, 0].View = captionModel; string[] strArray = new string[] { "Value 1", "Value 2" }; grid[currentRow, 1] = new SourceGrid.Cells.Cell(strArray, typeof(string[])); currentRow++; //Double[] grid[currentRow, 0] = new SourceGrid.Cells.Cell("Double Array"); grid[currentRow, 0].View = captionModel; double[] dblArray = new double[] { 1, 0.5, 0.1 }; grid[currentRow, 1] = new SourceGrid.Cells.Cell(dblArray, typeof(double[])); currentRow++; #endregion #region Special Editors grid[currentRow, 0] = new SourceGrid.Cells.Cell("Special Editors"); grid[currentRow, 0].View = titleModel; grid[currentRow, 0].ColumnSpan = 3; currentRow++; //Time grid[currentRow, 0] = new SourceGrid.Cells.Cell("Time"); grid[currentRow, 0].View = captionModel; grid[currentRow, 1] = new SourceGrid.Cells.Cell(DateTime.Now); grid[currentRow, 1].Editor = new SourceGrid.Cells.Editors.TimePicker(); currentRow++; //Double Chars Validation grid[currentRow, 0] = new SourceGrid.Cells.Cell("Double Chars Validation"); grid[currentRow, 0].View = captionModel; SourceGrid.Cells.Editors.TextBoxNumeric numericEditor = new SourceGrid.Cells.Editors.TextBoxNumeric(typeof(double)); numericEditor.KeyPress += delegate(object sender, KeyPressEventArgs keyArgs) { bool isValid = char.IsNumber(keyArgs.KeyChar) || keyArgs.KeyChar == System.Globalization.CultureInfo.CurrentCulture.NumberFormat.NumberDecimalSeparator[0]; keyArgs.Handled = !isValid; }; grid[currentRow, 1] = new SourceGrid.Cells.Cell(0.5); grid[currentRow, 1].Editor = numericEditor; currentRow++; //String Chars (ABC) grid[currentRow, 0] = new SourceGrid.Cells.Cell("Chars Validation(only ABC)"); grid[currentRow, 0].View = captionModel; SourceGrid.Cells.Editors.TextBox stringEditor = new SourceGrid.Cells.Editors.TextBox(typeof(string)); stringEditor.KeyPress += delegate(object sender, KeyPressEventArgs keyArgs) { keyArgs.KeyChar = char.ToUpper(keyArgs.KeyChar); bool isValid = keyArgs.KeyChar == 'A' || keyArgs.KeyChar == 'B' || keyArgs.KeyChar == 'C'; keyArgs.Handled = !isValid; }; grid[currentRow, 1] = new SourceGrid.Cells.Cell("AABB"); grid[currentRow, 1].Editor = stringEditor; currentRow++; //String Validating grid[currentRow, 0] = new SourceGrid.Cells.Cell("String validating(min 6 chars)"); grid[currentRow, 0].View = captionModel; SourceGrid.Cells.Editors.TextBox stringEditorValidating = new SourceGrid.Cells.Editors.TextBox(typeof(string)); stringEditorValidating.Control.Validating += delegate(object sender, CancelEventArgs cancelEvent) { string val = ((TextBox)sender).Text; if (val == null || val.Length < 6) cancelEvent.Cancel = true; }; grid[currentRow, 1] = new SourceGrid.Cells.Cell("test string"); grid[currentRow, 1].Editor = stringEditorValidating; currentRow++; //Int 0-100 or null grid[currentRow, 0] = new SourceGrid.Cells.Cell("Int 0-100 or null"); grid[currentRow, 0].View = captionModel; SourceGrid.Cells.Editors.TextBoxNumeric numericEditor0_100 = new SourceGrid.Cells.Editors.TextBoxNumeric(typeof(int)); numericEditor0_100.MinimumValue = 0; numericEditor0_100.MaximumValue = 100; numericEditor0_100.AllowNull = true; grid[currentRow, 1] = new SourceGrid.Cells.Cell(7); grid[currentRow, 1].Editor = numericEditor0_100; currentRow++; //Double Custom Conversion grid[currentRow, 0] = new SourceGrid.Cells.Cell("Dbl custom conversion"); grid[currentRow, 0].View = captionModel; SourceGrid.Cells.Editors.TextBox dblCustomConversion = new SourceGrid.Cells.Editors.TextBox(typeof(double)); dblCustomConversion.ConvertingObjectToValue += delegate(object sender, DevAge.ComponentModel.ConvertingObjectEventArgs conv) { if (conv.Value is string) { //Here you can add any custom code double val; if (double.TryParse((string)conv.Value, out val)) { conv.Value = val; conv.ConvertingStatus = DevAge.ComponentModel.ConvertingStatus.Completed; } } }; grid[currentRow, 1] = new SourceGrid.Cells.Cell(73.839); grid[currentRow, 1].Editor = dblCustomConversion; currentRow++; //Enum Custom Display grid[currentRow, 0] = new SourceGrid.Cells.Cell("Enum Custom Display"); grid[currentRow, 0].View = captionModel; SourceGrid.Cells.Editors.ComboBox keysCombo = new SourceGrid.Cells.Editors.ComboBox(typeof(Keys)); keysCombo.Control.FormattingEnabled = true; keysCombo.ConvertingValueToDisplayString += delegate(object sender, DevAge.ComponentModel.ConvertingObjectEventArgs convArgs) { if (convArgs.Value is Keys) convArgs.Value = (int)((Keys)convArgs.Value) + " - " + convArgs.Value.ToString(); }; grid[currentRow, 1] = new SourceGrid.Cells.Cell(Keys.Enter); grid[currentRow, 1].Editor = keysCombo; currentRow++; string[] arraySample = new string[] { "Value 1", "Value 2", "Value 3" }; //ComboBox 1 grid[currentRow, 0] = new SourceGrid.Cells.Cell("ComboBox String"); grid[currentRow, 0].View = captionModel; SourceGrid.Cells.Editors.ComboBox comboStandard = new SourceGrid.Cells.Editors.ComboBox(typeof(string), arraySample, false); comboStandard.Control.MaxLength = 10; grid[currentRow, 1] = new SourceGrid.Cells.Cell(arraySample[0], comboStandard); currentRow++; //ComboBox exclusive grid[currentRow, 0] = new SourceGrid.Cells.Cell("ComboBox String Exclusive"); grid[currentRow, 0].View = captionModel; SourceGrid.Cells.Editors.ComboBox comboExclusive = new SourceGrid.Cells.Editors.ComboBox(typeof(string), arraySample, true); grid[currentRow, 1] = new SourceGrid.Cells.Cell(arraySample[0], comboExclusive); currentRow++; //ComboBox AutoComplete grid[currentRow, 0] = new SourceGrid.Cells.Cell("ComboBox AutoComplete"); grid[currentRow, 0].View = captionModel; SourceGrid.Cells.Editors.ComboBox comboAutoComplete = new SourceGrid.Cells.Editors.ComboBox(typeof(string), new string[] { "AAA", "ABC", "AZA", "BAA", "ZAA" }, true); comboAutoComplete.Control.AutoCompleteSource = AutoCompleteSource.ListItems; comboAutoComplete.Control.AutoCompleteMode = AutoCompleteMode.Append; grid[currentRow, 1] = new SourceGrid.Cells.Cell("AAA", comboAutoComplete); currentRow++; //ComboBox DropDownList grid[currentRow, 0] = new SourceGrid.Cells.Cell("ComboBox DropDownList"); grid[currentRow, 0].View = captionModel; SourceGrid.Cells.Editors.ComboBox comboNoText = new SourceGrid.Cells.Editors.ComboBox(typeof(string), arraySample, true); grid[currentRow, 1] = new SourceGrid.Cells.Cell(arraySample[0]); grid[currentRow, 1].Editor = comboNoText; comboNoText.Control.DropDownStyle = ComboBoxStyle.DropDownList; currentRow++; //ComboBox DateTime Editable grid[currentRow, 0] = new SourceGrid.Cells.Cell("ComboBox DateTime"); grid[currentRow, 0].View = captionModel; DateTime[] arrayDt = new DateTime[] { new DateTime(1981, 10, 6), new DateTime(1991, 10, 6), new DateTime(2001, 10, 6) }; SourceGrid.Cells.Editors.ComboBox comboDateTime = new SourceGrid.Cells.Editors.ComboBox(typeof(DateTime), arrayDt, false); grid[currentRow, 1] = new SourceGrid.Cells.Cell(arrayDt[0], comboDateTime); currentRow++; //ComboBox Custom Display (create a datamodel that has a custom display string) grid[currentRow, 0] = new SourceGrid.Cells.Cell("ComboBox Custom Display"); grid[currentRow, 0].View = captionModel; int[] arrInt = new int[] { 0, 1, 2, 3, 4 }; string[] arrStr = new string[] { "0 - Zero", "1 - One", "2 - Two", "3 - Three", "4- Four" }; SourceGrid.Cells.Editors.ComboBox editorComboCustomDisplay = new SourceGrid.Cells.Editors.ComboBox(typeof(int), arrInt, true); editorComboCustomDisplay.Control.FormattingEnabled = true; DevAge.ComponentModel.Validator.ValueMapping comboMapping = new DevAge.ComponentModel.Validator.ValueMapping(); comboMapping.DisplayStringList = arrStr; comboMapping.ValueList = arrInt; comboMapping.SpecialList = arrStr; comboMapping.SpecialType = typeof(string); comboMapping.BindValidator(editorComboCustomDisplay); grid[currentRow, 1] = new SourceGrid.Cells.Cell(0); grid[currentRow, 1].Editor = editorComboCustomDisplay; SourceGrid.Cells.Cell l_CellComboRealValue = new SourceGrid.Cells.Cell(grid[currentRow, 1].Value); l_CellComboRealValue.View = captionModel; SourceGrid.Cells.Controllers.BindProperty l_ComboBindProperty = new SourceGrid.Cells.Controllers.BindProperty(typeof(SourceGrid.Cells.Cell).GetProperty("Value"), l_CellComboRealValue); grid[currentRow, 1].AddController(l_ComboBindProperty); grid[currentRow, 2] = l_CellComboRealValue; currentRow++; //ComboBox with inline View grid[currentRow, 0] = new SourceGrid.Cells.Cell("ComboBox Inline View"); grid[currentRow, 0].View = captionModel; SourceGrid.Cells.Editors.ComboBox cbInline = new SourceGrid.Cells.Editors.ComboBox(typeof(string), arraySample, false); cbInline.EditableMode = SourceGrid.EditableMode.Default | SourceGrid.EditableMode.Focus; grid[currentRow, 1] = new SourceGrid.Cells.Cell(arraySample[0], cbInline); grid[currentRow, 1].View = SourceGrid.Cells.Views.ComboBox.Default; currentRow++; //Numeric Up Down Editor grid[currentRow, 0] = new SourceGrid.Cells.Cell("NumericUpDown"); grid[currentRow, 0].View = captionModel; grid[currentRow, 1] = new SourceGrid.Cells.Cell(0); SourceGrid.Cells.Editors.NumericUpDown l_NumericUpDownEditor = new SourceGrid.Cells.Editors.NumericUpDown(typeof(int), 50, -50, 1); grid[currentRow, 1].Editor = l_NumericUpDownEditor; currentRow++; //Multiline Textbox grid[currentRow, 0] = new SourceGrid.Cells.Cell("Multiline Textbox"); grid[currentRow, 0].View = captionModel; grid[currentRow, 0].ColumnSpan = 1; grid[currentRow, 0].RowSpan = 2; grid[currentRow, 1] = new SourceGrid.Cells.Cell("Hello\r\nWorld"); SourceGrid.Cells.Editors.TextBox l_MultilineEditor = new SourceGrid.Cells.Editors.TextBox(typeof(string)); l_MultilineEditor.Control.Multiline = true; grid[currentRow, 1].Editor = l_MultilineEditor; grid[currentRow, 1].RowSpan = 2; currentRow++; currentRow++; //Boolean (CheckBox) grid[currentRow, 0] = new SourceGrid.Cells.Cell("Boolean (CheckBox)"); grid[currentRow, 0].View = captionModel; grid[currentRow, 1] = new SourceGrid.Cells.CheckBox(null, true); grid[currentRow, 1].FindController<SourceGrid.Cells.Controllers.CheckBox>().CheckedChanged += InvertDisabledCheckBox(currentRow); SourceGrid.Cells.CheckBox l_DisabledCheckBox = new SourceGrid.Cells.CheckBox("Disabled Checkbox", true); l_DisabledCheckBox.Editor.EnableEdit = false; grid[currentRow, 2] = l_DisabledCheckBox; currentRow++; //DateTime with DateTimePicker Editor grid[currentRow, 0] = new SourceGrid.Cells.Cell("DateTimePicker"); grid[currentRow, 0].View = captionModel; SourceGrid.Cells.Editors.DateTimePicker editorDtPicker = new SourceGrid.Cells.Editors.DateTimePicker(); grid[currentRow, 1] = new SourceGrid.Cells.Cell(DateTime.Today); grid[currentRow, 1].Editor = editorDtPicker; currentRow++; //DateTime with DateTimePicker nullable Editor grid[currentRow, 0] = new SourceGrid.Cells.Cell("DateTimePicker nullable"); grid[currentRow, 0].View = captionModel; SourceGrid.Cells.Editors.DateTimePicker editorDtPickerNull = new SourceGrid.Cells.Editors.DateTimePicker(); editorDtPickerNull.AllowNull = true; grid[currentRow, 1] = new SourceGrid.Cells.Cell(null); grid[currentRow, 1].Editor = editorDtPickerNull; currentRow++; //File editor grid[currentRow, 0] = new SourceGrid.Cells.Cell("File editor"); grid[currentRow, 0].View = captionModel; grid[currentRow, 1] = new SourceGrid.Cells.Cell("c:\\windows\\System32\\user32.dll", new EditorFileDialog()); currentRow++; // Richtext box grid[currentRow, 0] = new SourceGrid.Cells.Cell("RichTextBox editor"); grid[currentRow, 0].View = captionModel; string rtf = "{\\rtf1\\ansi\\ansicpg1252\\deff0\\deflang1033{\\fonttbl{\\f0\\fnil\\fcharset0" + "Microsoft Sans Serif;}}\r\n\\viewkind4\\uc1\\pard\\f0\\fs17 Only a \\b " + "Test\\b0.\\par\r\n}\r\n"; var richTextBox = new SourceGrid.Cells.RichTextBox(new RichText(rtf)); grid[currentRow, 1] = richTextBox; currentRow++; #endregion #region Special Cells grid[currentRow, 0] = new SourceGrid.Cells.Cell("Special Cells"); grid[currentRow, 0].View = titleModel; grid[currentRow, 0].ColumnSpan = 3; currentRow++; //Cell Button grid[currentRow, 0] = new SourceGrid.Cells.Cell("Cell Button"); grid[currentRow, 0].View = captionModel; grid[currentRow, 1] = new SourceGrid.Cells.Button("CellButton"); grid[currentRow, 1].Image = Properties.Resources.FACE02.ToBitmap(); SourceGrid.Cells.Controllers.Button buttonClickEvent = new SourceGrid.Cells.Controllers.Button(); buttonClickEvent.Executed += new EventHandler(CellButton_Click); grid[currentRow, 1].Controller.AddController(buttonClickEvent); currentRow++; //Cell Link grid[currentRow, 0] = new SourceGrid.Cells.Cell("Cell Link"); grid[currentRow, 0].View = captionModel; grid[currentRow, 1] = new SourceGrid.Cells.Link("CellLink"); SourceGrid.Cells.Controllers.Button linkClickEvent = new SourceGrid.Cells.Controllers.Button(); linkClickEvent.Executed += new EventHandler(CellLink_Click); grid[currentRow, 1].Controller.AddController(linkClickEvent); currentRow++; //Custom draw cell grid[currentRow, 0] = new SourceGrid.Cells.Cell("Custom draw cell"); grid[currentRow, 0].View = captionModel; grid[currentRow, 1] = new SourceGrid.Cells.Cell("CustomView"); grid[currentRow, 1].View = new RoundView(); currentRow++; //Control Cell grid[currentRow, 0] = new SourceGrid.Cells.Cell("Control Cell"); grid[currentRow, 0].View = captionModel; grid[currentRow, 1] = new SourceGrid.Cells.Cell("control cell"); ProgressBar progressBar = new ProgressBar(); progressBar.Value = 50; grid.LinkedControls.Add(new SourceGrid.LinkedControlValue(progressBar, new SourceGrid.Position(currentRow, 1))); currentRow++; //Custom Border Cell grid[currentRow, 0] = new SourceGrid.Cells.Cell("Custom Border"); grid[currentRow, 0].View = captionModel; SourceGrid.Cells.Views.Cell viewCustomBorder = new SourceGrid.Cells.Views.Cell(); viewCustomBorder.Border = new DevAge.Drawing.RectangleBorder(new DevAge.Drawing.BorderLine(Color.Red, 1), new DevAge.Drawing.BorderLine(Color.Blue, 1), new DevAge.Drawing.BorderLine(Color.Violet, 1), new DevAge.Drawing.BorderLine(Color.Green, 1)); grid[currentRow, 1] = new SourceGrid.Cells.Cell("Custom Border"); grid[currentRow, 1].View = viewCustomBorder; currentRow++; #endregion #region Custom Formatting grid[currentRow, 0] = new SourceGrid.Cells.Cell("Custom Formatting"); grid[currentRow, 0].View = titleModel; grid[currentRow, 0].ColumnSpan = 3; currentRow++; //Format grid[currentRow, 0] = new SourceGrid.Cells.Cell("Default Format"); grid[currentRow, 0].View = captionModel; grid[currentRow, 1] = new SourceGrid.Cells.Cell(88.5246); SourceGrid.Cells.Editors.TextBox editorCustom = new SourceGrid.Cells.Editors.TextBox(typeof(double)); editorCustom.TypeConverter = new DevAge.ComponentModel.Converter.CurrencyTypeConverter(typeof(double)); DevAge.ComponentModel.Converter.NumberTypeConverter numberFormatCustom = new DevAge.ComponentModel.Converter.NumberTypeConverter(typeof(double)); editorCustom.TypeConverter = numberFormatCustom; grid[currentRow, 1].Editor = editorCustom; currentRow++; //Percent Editor grid[currentRow, 0] = new SourceGrid.Cells.Cell("Percent Format"); grid[currentRow, 0].View = captionModel; grid[currentRow, 1] = new SourceGrid.Cells.Cell(88.5246); SourceGrid.Cells.Editors.TextBox l_PercentEditor = new SourceGrid.Cells.Editors.TextBox(typeof(double)); l_PercentEditor.TypeConverter = new DevAge.ComponentModel.Converter.PercentTypeConverter(typeof(double)); grid[currentRow, 1].Editor = l_PercentEditor; currentRow++; //Currency Editor grid[currentRow, 0] = new SourceGrid.Cells.Cell("Currency Format"); grid[currentRow, 0].View = captionModel; grid[currentRow, 1] = new SourceGrid.Cells.Cell(88.5246M); SourceGrid.Cells.Editors.TextBox l_CurrencyEditor = new SourceGrid.Cells.Editors.TextBox(typeof(decimal)); l_CurrencyEditor.TypeConverter = new DevAge.ComponentModel.Converter.CurrencyTypeConverter(typeof(decimal)); grid[currentRow, 1].Editor = l_CurrencyEditor; currentRow++; //Format (#.00) grid[currentRow, 0] = new SourceGrid.Cells.Cell("Format #.00"); grid[currentRow, 0].View = captionModel; grid[currentRow, 1] = new SourceGrid.Cells.Cell(88.5246); editorCustom = new SourceGrid.Cells.Editors.TextBox(typeof(double)); numberFormatCustom = new DevAge.ComponentModel.Converter.NumberTypeConverter(typeof(double)); numberFormatCustom.Format = "#.00"; editorCustom.TypeConverter = numberFormatCustom; grid[currentRow, 1].Editor = editorCustom; currentRow++; //Format ("0000.0000") grid[currentRow, 0] = new SourceGrid.Cells.Cell("Format 0000.0000"); grid[currentRow, 0].View = captionModel; grid[currentRow, 1] = new SourceGrid.Cells.Cell(88.5246); editorCustom = new SourceGrid.Cells.Editors.TextBox(typeof(double)); numberFormatCustom = new DevAge.ComponentModel.Converter.NumberTypeConverter(typeof(double)); numberFormatCustom.Format = "0000.0000"; editorCustom.TypeConverter = numberFormatCustom; grid[currentRow, 1].Editor = editorCustom; currentRow++; //Format ("Scientific (exponential)") grid[currentRow, 0] = new SourceGrid.Cells.Cell("Format Scientific"); grid[currentRow, 0].View = captionModel; grid[currentRow, 1] = new SourceGrid.Cells.Cell(0.0006); SourceGrid.Cells.Editors.TextBoxNumeric editorExponential = new SourceGrid.Cells.Editors.TextBoxNumeric(typeof(double)); DevAge.ComponentModel.Converter.NumberTypeConverter exponentialConverter = new DevAge.ComponentModel.Converter.NumberTypeConverter(typeof(double), "e"); exponentialConverter.NumberStyles = System.Globalization.NumberStyles.Float | System.Globalization.NumberStyles.AllowExponent; editorExponential.TypeConverter = exponentialConverter; grid[currentRow, 1].Editor = editorExponential; currentRow++; //DateTime 2 (using custom formatting) string dtFormat2 = "yyyy MM dd"; grid[currentRow, 0] = new SourceGrid.Cells.Cell("Date(" + dtFormat2 + ")"); grid[currentRow, 0].View = captionModel; string[] dtParseFormats = new string[] { dtFormat2 }; System.Globalization.DateTimeStyles dtStyles = System.Globalization.DateTimeStyles.AllowInnerWhite | System.Globalization.DateTimeStyles.AllowLeadingWhite | System.Globalization.DateTimeStyles.AllowTrailingWhite | System.Globalization.DateTimeStyles.AllowWhiteSpaces; TypeConverter dtConverter = new DevAge.ComponentModel.Converter.DateTimeTypeConverter(dtFormat2, dtParseFormats, dtStyles); SourceGrid.Cells.Editors.TextBoxUITypeEditor editorDt2 = new SourceGrid.Cells.Editors.TextBoxUITypeEditor(typeof(DateTime)); editorDt2.TypeConverter = dtConverter; grid[currentRow, 1] = new SourceGrid.Cells.Cell(DateTime.Today); grid[currentRow, 1].Editor = editorDt2; currentRow++; //Text Ellipses grid[currentRow, 0] = new SourceGrid.Cells.Cell("Text Ellipses"); grid[currentRow, 0].View = captionModel; grid[currentRow, 1] = new SourceGrid.Cells.Cell("This text is very very long and shows how to trim and add ellipses", typeof(string)); SourceGrid.Cells.Views.Cell ellipsesView = new SourceGrid.Cells.Views.Cell(); ellipsesView.TrimmingMode = SourceGrid.TrimmingMode.Word; grid[currentRow, 1].View = ellipsesView; currentRow++; #endregion #region Image And Text Properties grid[currentRow, 0] = new SourceGrid.Cells.Cell("Image And Text Properties"); grid[currentRow, 0].View = titleModel; grid[currentRow, 0].ColumnSpan = 3; currentRow++; //Cell Image SourceGrid.Cells.Cell cellImage1 = new SourceGrid.Cells.Cell("Single Image"); SourceGrid.Cells.Views.Cell viewImage = new SourceGrid.Cells.Views.Cell(captionModel); cellImage1.View = viewImage; grid[currentRow, 2] = cellImage1; cellImage1.RowSpan = 4; cellImage1.Image = Properties.Resources.FACE02.ToBitmap(); grid[currentRow, 0] = new SourceGrid.Cells.Cell("Image Alignment"); grid[currentRow, 0].View = captionModel; grid[currentRow, 1] = new SourceGrid.Cells.Cell(viewImage.ImageAlignment, typeof(DevAge.Drawing.ContentAlignment)); grid[currentRow, 1].AddController(new SourceGrid.Cells.Controllers.BindProperty(typeof(SourceGrid.Cells.Views.Cell).GetProperty("ImageAlignment"), viewImage)); currentRow++; grid[currentRow, 0] = new SourceGrid.Cells.Cell("Stretch Image"); grid[currentRow, 0].View = captionModel; grid[currentRow, 1] = new SourceGrid.Cells.Cell(viewImage.ImageStretch, typeof(bool)); grid[currentRow, 1].AddController(new SourceGrid.Cells.Controllers.BindProperty(typeof(SourceGrid.Cells.Views.Cell).GetProperty("ImageStretch"), viewImage)); currentRow++; grid[currentRow, 0] = new SourceGrid.Cells.Cell("Text Alignment"); grid[currentRow, 0].View = captionModel; grid[currentRow, 1] = new SourceGrid.Cells.Cell(viewImage.TextAlignment, typeof(DevAge.Drawing.ContentAlignment)); grid[currentRow, 1].AddController(new SourceGrid.Cells.Controllers.BindProperty(typeof(SourceGrid.Cells.Views.Cell).GetProperty("TextAlignment"), viewImage)); currentRow++; grid[currentRow, 0] = new SourceGrid.Cells.Cell("DrawMode"); grid[currentRow, 0].View = captionModel; grid[currentRow, 1] = new SourceGrid.Cells.Cell(viewImage.ElementsDrawMode, typeof(DevAge.Drawing.ElementsDrawMode)); grid[currentRow, 1].AddController(new SourceGrid.Cells.Controllers.BindProperty(typeof(SourceGrid.Cells.Views.Cell).GetProperty("ElementsDrawMode"), viewImage)); currentRow++; // Cell VisualModelMultiImages grid[currentRow, 1] = new SourceGrid.Cells.Cell("Multi Images"); SourceGrid.Cells.Views.MultiImages modelMultiImages = new SourceGrid.Cells.Views.MultiImages(); modelMultiImages.SubImages.Add(new DevAge.Drawing.VisualElements.Image(Properties.Resources.FACE00.ToBitmap())); modelMultiImages.SubImages.Add(new DevAge.Drawing.VisualElements.Image(Properties.Resources.FACE01.ToBitmap())); modelMultiImages.SubImages.Add(new DevAge.Drawing.VisualElements.Image(Properties.Resources.FACE02.ToBitmap())); modelMultiImages.SubImages.Add(new DevAge.Drawing.VisualElements.Image(Properties.Resources.FACE04.ToBitmap())); modelMultiImages.SubImages[0].AnchorArea = new DevAge.Drawing.AnchorArea(DevAge.Drawing.ContentAlignment.TopLeft, false); modelMultiImages.SubImages[1].AnchorArea = new DevAge.Drawing.AnchorArea(DevAge.Drawing.ContentAlignment.TopRight, false); modelMultiImages.SubImages[2].AnchorArea = new DevAge.Drawing.AnchorArea(DevAge.Drawing.ContentAlignment.BottomLeft, false); modelMultiImages.SubImages[3].AnchorArea = new DevAge.Drawing.AnchorArea(DevAge.Drawing.ContentAlignment.BottomRight, false); modelMultiImages.TextAlignment = DevAge.Drawing.ContentAlignment.MiddleCenter; grid[currentRow, 1].View = modelMultiImages; grid.Rows[currentRow].AutoSizeMode = SourceGrid.AutoSizeMode.MinimumSize; grid.Rows[currentRow].Height = 50; currentRow++; // Cell Rotated Text grid[currentRow, 0] = new SourceGrid.Cells.Cell("Rotated by angle"); grid[currentRow, 0].View = captionModel; grid[currentRow, 1] = new SourceGrid.Cells.Cell("Rotated Text", typeof(string)); SourceGrid.Cells.Views.Cell rotateView = new SourceGrid.Cells.Views.Cell(); rotateView.ElementText = new RotatedText(45); grid[currentRow, 1].View = rotateView; grid.Rows[currentRow].AutoSizeMode = SourceGrid.AutoSizeMode.MinimumSize; grid.Rows[currentRow].Height = 50; currentRow++; // GDI+ Text grid[currentRow, 0] = new SourceGrid.Cells.Cell("GDI+ Text"); grid[currentRow, 0].View = captionModel; grid[currentRow, 1] = new SourceGrid.Cells.Cell("Hello from GDI+", typeof(string)); GDITextView gdiTextView = new GDITextView(); gdiTextView.FormatFlags = StringFormatFlags.DirectionVertical | StringFormatFlags.NoWrap; grid[currentRow, 1].View = gdiTextView; currentRow++; #endregion grid.Columns[0].AutoSizeMode = SourceGrid.AutoSizeMode.MinimumSize | SourceGrid.AutoSizeMode.Default; grid.Columns[1].AutoSizeMode = SourceGrid.AutoSizeMode.MinimumSize | SourceGrid.AutoSizeMode.Default; grid.Columns[2].AutoSizeMode = SourceGrid.AutoSizeMode.MinimumSize | SourceGrid.AutoSizeMode.Default; grid.MinimumWidth = 50; grid.AutoSizeCells(); grid.AutoStretchColumnsToFitWidth = true; grid.Columns.StretchToFit(); }
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; }
public void InitArtGrid() { _editorsArt = new List <SourceGrid.Cells.Editors.EditorBase>(); var editStr5 = new SourceGrid.Cells.Editors.TextBox(typeof(string)); editStr5.Control.Validating += delegate(object sender, CancelEventArgs cancelEvent) { StringMaxLen((TextBox)sender, cancelEvent, 5); }; var editStr50 = new SourceGrid.Cells.Editors.TextBox(typeof(string)); editStr50.Control.Validating += delegate(object sender, CancelEventArgs cancelEvent) { StringMaxLen((TextBox)sender, cancelEvent, 50); }; var editStr100 = new SourceGrid.Cells.Editors.TextBox(typeof(string)); editStr100.Control.Validating += delegate(object sender, CancelEventArgs cancelEvent) { StringMaxLen((TextBox)sender, cancelEvent, 100); }; var editInt = SourceGrid.Cells.Editors.Factory.Create(typeof(int)); var editIntNull = SourceGrid.Cells.Editors.Factory.Create(typeof(int)); editIntNull.AllowNull = true; _editArt = new SourceGrid.Cells.Editors.ComboBox(typeof(string)); _editArt.Control.AutoCompleteSource = AutoCompleteSource.ListItems; _editArt.Control.AutoCompleteMode = AutoCompleteMode.SuggestAppend; _editArt.Control.Validating += delegate(object sender, CancelEventArgs cancelEvent) { var text = ((ComboBox)sender).Text; if (!string.IsNullOrEmpty(text) && _arts.All(x => x.Name != text)) { cancelEvent.Cancel = true; } }; _editorsArt.Add(null); _editorsArt.Add(editStr5); _editorsArt.Add(editInt); _editorsArt.Add(editStr5); _editorsArt.Add(editStr50); _editorsArt.Add(editStr100); _editorsArt.Add(editIntNull); _editorsArt.Add(editStr50); _editorsArt.Add(null); _editorsArt.Add(null); gridArt.ColumnsCount = 10; gridArt.RowsCount = 1; gridArt.FixedRows = 1; gridArt[0, 0] = new SourceGrid.Cells.ColumnHeader("ArtId"); gridArt.Columns[0].Visible = false; gridArt[0, 1] = new SourceGrid.Cells.ColumnHeader("Mag"); gridArt[0, 2] = new SourceGrid.Cells.ColumnHeader("IYear"); gridArt[0, 3] = new SourceGrid.Cells.ColumnHeader("IMonth"); gridArt[0, 4] = new SourceGrid.Cells.ColumnHeader("Author"); gridArt[0, 5] = new SourceGrid.Cells.ColumnHeader("Name"); gridArt[0, 6] = new SourceGrid.Cells.ColumnHeader("NN"); gridArt[0, 7] = new SourceGrid.Cells.ColumnHeader("Serie"); gridArt[0, 8] = new SourceGrid.Cells.ColumnHeader("Pics"); gridArt[0, 9] = new SourceGrid.Cells.ColumnHeader("Art"); for (var i = 1; i < gridArt.ColumnsCount; i++) { var key = $"gridArt:ColumnWidth:{i}"; if (_config.ContainsKey(key)) { gridArt.Columns[i].Width = int.Parse(_config[key]); } } _gridArtController = new GridArtController(this); gridArt.Selection.CellGotFocus += ArtCellGotFocus; gridArt.Columns.ColumnWidthChanged += ArtColumnWidthChanged; }
protected override void OnLoad(EventArgs e) { base.OnLoad(e); grid1.Redim(30, 2); grid1[0, 0] = new SourceGrid.Cells.ColumnHeader("Checked"); grid1[0, 1] = new SourceGrid.Cells.ColumnHeader("CheckStatus"); SourceGrid.Cells.Editors.ComboBox combo = new SourceGrid.Cells.Editors.ComboBox(typeof(DevAge.Drawing.CheckBoxState)); DependencyColumn boolToStatus = new DependencyColumn(1); boolToStatus.ConvertFunction = delegate(object valBool) { if (valBool == null) { return(DevAge.Drawing.CheckBoxState.Undefined); } else if ((bool)valBool == true) { return(DevAge.Drawing.CheckBoxState.Checked); } else { return(DevAge.Drawing.CheckBoxState.Unchecked); } }; DependencyColumn statusToBool = new DependencyColumn(0); statusToBool.ConvertFunction = delegate(object valStatus) { DevAge.Drawing.CheckBoxState status = (DevAge.Drawing.CheckBoxState)valStatus; if (status == DevAge.Drawing.CheckBoxState.Undefined) { return(null); } else if (status == DevAge.Drawing.CheckBoxState.Checked) { return(true); } else { return(false); } }; for (int r = 1; r < grid1.RowsCount; r++) { grid1[r, 0] = new SourceGrid.Cells.CheckBox(null, null); grid1[r, 0].Editor.AllowNull = true; grid1[r, 0].AddController(boolToStatus); grid1[r, 1] = new SourceGrid.Cells.Cell(DevAge.Drawing.CheckBoxState.Undefined, combo); grid1[r, 1].AddController(statusToBool); } grid1.AutoSizeCells(); }
private static void CreateColumns(SourceGrid.DataGridColumns columns, DataTable sourceTable) { 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.TextBox stringEditor = new SourceGrid.Cells.Editors.TextBox(typeof(string)); SourceGrid.Cells.Editors.ComboBox externalIdEditor = new SourceGrid.Cells.Editors.ComboBox(typeof(int)); externalIdEditor.StandardValues = new int[] { 1, 2, 3, 4 }; externalIdEditor.StandardValuesExclusive = true; DevAge.ComponentModel.Validator.ValueMapping mapping = new DevAge.ComponentModel.Validator.ValueMapping(); mapping.ValueList = new int[] { 1, 2, 3, 4 }; mapping.SpecialType = typeof(string); mapping.SpecialList = new string[] { "Reference 1", "Reference 2", "Reference 3", "Reference 4" }; mapping.ThrowErrorIfNotFound = false; mapping.BindValidator(externalIdEditor); DataColumn dataColumn; SourceGrid.DataGridColumn gridColumn; SourceGrid.Cells.ICellVirtual dataCell; //Create columns dataColumn = sourceTable.Columns["Selected"]; dataCell = new SourceGrid.Cells.DataGrid.CheckBox(dataColumn); gridColumn = new MyDataGridColumn(columns.Grid, dataColumn, dataColumn.Caption, dataCell); columns.Insert(columns.Count, gridColumn); dataColumn = sourceTable.Columns["Country"]; dataCell = new SourceGrid.Cells.DataGrid.Cell(dataColumn); dataCell.Editor = stringEditor; gridColumn = new MyDataGridColumn(columns.Grid, dataColumn, dataColumn.Caption, dataCell); columns.Insert(columns.Count, gridColumn); dataColumn = sourceTable.Columns["Uniform"]; dataCell = new SourceGrid.Cells.DataGrid.Image(dataColumn); gridColumn = new MyDataGridColumn(columns.Grid, dataColumn, dataColumn.Caption, dataCell); columns.Insert(columns.Count, gridColumn); dataColumn = sourceTable.Columns["Population"]; dataCell = new SourceGrid.Cells.DataGrid.Cell(dataColumn); dataCell.Editor = numericEditor; gridColumn = new MyDataGridColumn(columns.Grid, dataColumn, dataColumn.Caption, dataCell); columns.Insert(columns.Count, gridColumn); dataColumn = sourceTable.Columns["Surface"]; dataCell = new SourceGrid.Cells.DataGrid.Cell(dataColumn); dataCell.Editor = numericEditor; gridColumn = new MyDataGridColumn(columns.Grid, dataColumn, dataColumn.Caption, dataCell); columns.Insert(columns.Count, gridColumn); dataColumn = sourceTable.Columns["ExternalID"]; dataCell = new SourceGrid.Cells.DataGrid.Cell(dataColumn); dataCell.Editor = externalIdEditor; gridColumn = new MyDataGridColumn(columns.Grid, dataColumn, dataColumn.Caption, dataCell); columns.Insert(columns.Count, gridColumn); gridColumn = new MyDataGridColumnStar(columns.Grid, "Star"); columns.Insert(columns.Count, gridColumn); }
/// <summary> /// load the transactions into the grid /// </summary> /// <param name="ALedgerNumber"></param> /// <param name="ABatchNumber"></param> /// <param name="AJournalNumber"></param> /// <param name="ACurrencyCode"></param> /// <param name="AFromBatchTab"></param> /// <returns>True if new GL transactions were loaded, false if transactions had been loaded already.</returns> public bool LoadRecurringTransactions(Int32 ALedgerNumber, Int32 ABatchNumber, Int32 AJournalNumber, string ACurrencyCode, bool AFromBatchTab = false) { bool DifferentBatchSelected = false; bool HadChangesFromTheStart = FPetraUtilsObject.HasChanges; FLoadCompleted = false; FBatchRow = GetRecurringBatchRow(); FJournalRow = GetRecurringJournalRow(); if (FLedgerNumber == -1) { InitialiseControls(); } //Check if the same batch is selected, so no need to apply filter if ((FLedgerNumber == ALedgerNumber) && (FBatchNumber == ABatchNumber) && (FJournalNumber == AJournalNumber) && (FTransactionCurrency == ACurrencyCode) && (FMainDS.ARecurringTransaction.DefaultView.Count > 0)) { //Same as previously selected if (GetSelectedRowIndex() > 0) { if (AFromBatchTab) { SelectRowInGrid(GetSelectedRowIndex()); } else { GetDetailsFromControls(GetSelectedDetailRow()); } } FLoadCompleted = true; } else { // Different batch DifferentBatchSelected = true; bool requireControlSetup = (FLedgerNumber == -1) || (FTransactionCurrency != ACurrencyCode); FLedgerNumber = ALedgerNumber; FBatchNumber = ABatchNumber; FJournalNumber = AJournalNumber; FTransactionNumber = -1; FTransactionCurrency = ACurrencyCode; FPreviouslySelectedDetailRow = null; grdDetails.SuspendLayout(); //Empty grids before filling them grdDetails.DataSource = null; grdAnalAttributes.DataSource = null; // This sets the main part of the filter but excluding the additional items set by the user GUI // It gets the right sort order SetTransactionDefaultView(); //Load from server if necessary if (FMainDS.ARecurringTransaction.DefaultView.Count == 0) { FMainDS.Merge(TRemote.MFinance.GL.WebConnectors.LoadARecurringTransactionARecurringTransAnalAttrib(ALedgerNumber, ABatchNumber, AJournalNumber)); } // We need to call this because we have not called ShowData(), which would have set it. This differs from the Gift screen. grdDetails.DataSource = new DevAge.ComponentModel.BoundDataView(FMainDS.ARecurringTransaction.DefaultView); // Now we set the full filter FFilterAndFindObject.ApplyFilter(); if (grdAnalAttributes.Columns.Count == 1) { grdAnalAttributes.SpecialKeys = GridSpecialKeys.Default | GridSpecialKeys.Tab; FcmbAnalAttribValues = new SourceGrid.Cells.Editors.ComboBox(typeof(string)); FcmbAnalAttribValues.EnableEdit = true; FcmbAnalAttribValues.EditableMode = EditableMode.Focus; grdAnalAttributes.AddTextColumn("Value", FMainDS.ARecurringTransAnalAttrib.Columns[ARecurringTransAnalAttribTable.GetAnalysisAttributeValueDBName()], 100, FcmbAnalAttribValues); FcmbAnalAttribValues.Control.SelectedValueChanged += new EventHandler(this.AnalysisAttributeValueChanged); grdAnalAttributes.Columns[0].Width = 99; } FAnalysisAttributesLogic = new TAnalysisAttributes(FLedgerNumber, FBatchNumber, FJournalNumber); FAnalysisAttributesLogic.SetRecurringTransAnalAttributeDefaultView(FMainDS); FMainDS.ARecurringTransAnalAttrib.DefaultView.AllowNew = false; grdAnalAttributes.DataSource = new DevAge.ComponentModel.BoundDataView(FMainDS.ARecurringTransAnalAttrib.DefaultView); grdAnalAttributes.SetHeaderTooltip(0, Catalog.GetString("Type")); grdAnalAttributes.SetHeaderTooltip(1, Catalog.GetString("Value")); //Always show active and inactive values if (requireControlSetup) { //Load all analysis attribute values if (FCacheDS == null) { FCacheDS = TRemote.MFinance.GL.WebConnectors.LoadAAnalysisAttributes(FLedgerNumber, FActiveOnly); } SetupExtraGridFunctionality(); TFinanceControls.InitialiseAccountList(ref cmbDetailAccountCode, FLedgerNumber, true, false, FActiveOnly, false, ACurrencyCode, true); TFinanceControls.InitialiseCostCentreList(ref cmbDetailCostCentreCode, FLedgerNumber, true, false, FActiveOnly, false); } // This modifies the content of the text boxes that display the totals. This is not a user change. bool prev = FPetraUtilsObject.SuppressChangeDetection; FPetraUtilsObject.SuppressChangeDetection = true; UpdateTransactionTotals(); FPetraUtilsObject.SuppressChangeDetection = prev; grdDetails.ResumeLayout(); FLoadCompleted = true; } //Check for incorrect Exchange rate to base (mainly for existing Petra data) foreach (DataRowView drv in FMainDS.ARecurringTransaction.DefaultView) { ARecurringTransactionRow rtr = (ARecurringTransactionRow)drv.Row; if (rtr.ExchangeRateToBase == 0) { rtr.ExchangeRateToBase = 1; FPetraUtilsObject.HasChanges = true; } } if (FPetraUtilsObject.HasChanges && !HadChangesFromTheStart) { // This means we updated the transaction totals. We will save them behind the scenes since there were no other changes when we started ((TFrmRecurringGLBatch)ParentForm).SaveChanges(); FMainDS.ARecurringTransaction.AcceptChanges(); } ShowData(); SelectRowInGrid(1); ShowDetails(); //Needed because of how currency is handled UpdateChangeableStatus(); UpdateRecordNumberDisplay(); FFilterAndFindObject.SetRecordNumberDisplayProperties(); return DifferentBatchSelected; }
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 frmSample54_Load(object sender, System.EventArgs e) { grid1.BorderStyle = BorderStyle.FixedSingle; grid1.ColumnsCount = 4; grid1.FixedRows = 1; grid1.Rows.Insert(0); grid1.Selection.FocusStyle = FocusStyle.None; cbEditor = new SourceGrid.Cells.Editors.ComboBox(typeof(string)); cbEditor.StandardValues = new string[]{"Value 1", "Value 2", "Value 3"}; cbEditor.EditableMode = SourceGrid.EditableMode.Focus | SourceGrid.EditableMode.SingleClick | SourceGrid.EditableMode.AnyKey; grid1[0, 0] = new SourceGrid.Cells.ColumnHeader("String"); grid1[0, 1] = new SourceGrid.Cells.ColumnHeader("DateTime"); grid1[0, 2] = new SourceGrid.Cells.ColumnHeader("CheckBox"); grid1[0, 3] = new SourceGrid.Cells.ColumnHeader("ComboBox"); for (int r = 1; r < 10; r++) { grid1.Rows.Insert(r); PopulateRow(r); } grid1.AutoSizeCells(); numericUpDownRowIndex.Value = 0; numericUpDownRowIndex.Minimum = 1; numericUpDownRowIndex.Value = 3; buttonEditCell.Click += delegate { StartEdit(grid1.Selection.ActivePosition); }; }