/// <summary> /// Called during loading of the form /// Adds the available labels to the Selection box. /// </summary> private void SetLocalDataLabels() { double widthInCm; PDataLabelTable DataLabels; PDataLabelUseTable DataLabelUse; DataRow[] filteredRows; DataLabels = (PDataLabelTable)TDataCache.TMPartner.GetCacheablePartnerTable(TCacheablePartnerTablesEnum.DataLabelList); DataLabelUse = (PDataLabelUseTable)TDataCache.TMPartner.GetCacheablePartnerTable(TCacheablePartnerTablesEnum.DataLabelUseList); foreach (PDataLabelUseRow UseRow in DataLabelUse.Rows) { if ((UseRow.Use == "Bank") || (UseRow.Use == "Church") || (UseRow.Use == "Family") || (UseRow.Use == "Organisation") || (UseRow.Use == "Person") || (UseRow.Use == "Unit") || (UseRow.Use == "Venue")) { filteredRows = DataLabels.Select(PDataLabelTable.GetKeyDBName() + " = " + UseRow.DataLabelKey.ToString()); if (filteredRows.Length > 0) { PDataLabelRow row = (PDataLabelRow)filteredRows[0]; if (row.DataType == "char") { widthInCm = TPartnerColumnFunction.CharLengthToCM(row.CharLength); } else if (row.DataType == "partnerkey") { widthInCm = TPartnerColumnFunction.CharLengthToCM(10); } else if (row.DataType == "lookup") { widthInCm = TPartnerColumnFunction.CharLengthToCM(14); } else if (row.DataType == "boolean") { widthInCm = TPartnerColumnFunction.CharLengthToCM(5); } else { widthInCm = TPartnerColumnFunction.CharLengthToCM(10); } /* minimum width of column, so that the caption can be displayed (with a footnote number if necessary) */ if (widthInCm < 1.5) { widthInCm = 1.5; } FPetraUtilsObject.AddAvailableFunction(new TPartnerColumnFunction("DataLabelColumn", "param_label", row.Text, widthInCm)); //FPetraUtilsObject.AddAvailableFunction(new TPartnerColumnFunction(row.Text, "param_label", // "DataLabelColumn", widthInCm)); } } } }
/// <summary> /// This procedure will check if there are no changes to the currently selected column, /// and then will select the new column /// /// </summary> /// <param name="ASelectedColumn">the number of the selected column (starting with 1) /// if it is -1, the edit fields are disabled</param> /// <returns>true if the selection was successful. /// it could fail if there are changed fields in the current selection /// </returns> protected bool SelectColumn(System.Int32 ASelectedColumn) { /* first check if currently selected column is unchanged; */ /* has anything changed in the currently selected column? */ if (ColumnChanged(FSelectedColumn)) { if (!FDuringApplyOrCancel) { switch (MessageBox.Show("Do you want to lose your changes to this column?", "Cancel column?", MessageBoxButtons.YesNoCancel)) { case System.Windows.Forms.DialogResult.No: ApplyColumn(FSelectedColumn, false); FillColumnGrid(); break; case System.Windows.Forms.DialogResult.Cancel: return(false); default: break; } } /* if the column was new, it should be removed again */ /* the position of the column to be selected will change */ /* this does not work, because ASelectedColumn is probably 1 */ } if (ASelectedColumn > -1) { grdColumns.Selection.ResetSelection(false); grdColumns.Selection.SelectColumn(ASelectedColumn, true); this.btnRemoveColumn.Enabled = true; this.btnApply.Enabled = true; this.btnCancel.Enabled = true; this.btnAddColumn.Enabled = true; // should be able to add a column after the selected column int MaxColumns = FColumnParameters.Get("MaxDisplayColumns").ToInt(); this.btnMoveColumn2Right.Enabled = ((ASelectedColumn + 1) < MaxColumns); this.btnMoveColumn2Left.Enabled = (ASelectedColumn > 0); String calculation = FColumnParameters.GetOrDefault("param_calculation", ASelectedColumn, new TVariant(cmbCalculation.GetSelectedString())).ToString(); TPartnerColumnFunction Func = (TPartnerColumnFunction)GetFunction(calculation); if (Func != null) { cmbCalculation.SetSelectedString(Func.GetDisplayValue()); txtColumnWidth.Text = FColumnParameters.GetOrDefault("ColumnWidth", ASelectedColumn, new TVariant(Func.FColumnWidth)).ToString(); } cmbCalculation.Enabled = true; txtColumnWidth.Enabled = true; } else { /* unselect the column */ if (FSelectedColumn != -1) { /* grdColumns.Selection.SelectColumn(FSelectedColumn, false); */ grdColumns.Selection.ResetSelection(false); btnAddColumn.Focus(); } this.btnRemoveColumn.Enabled = false; this.btnApply.Enabled = false; this.btnCancel.Enabled = false; this.btnAddColumn.Enabled = true; this.btnMoveColumn2Right.Enabled = false; this.btnMoveColumn2Left.Enabled = false; cmbCalculation.Enabled = false; txtColumnWidth.Enabled = false; } this.FSelectedColumn = ASelectedColumn; return(true); }