private void InitializeManualCode()
        {
            // Initialize 'Helper Class' for handling the Indexes of the DataRows.
            FIndexedGridRowsHelper = new TSgrdDataGrid.IndexedGridRowsHelper(
                grdDetails, PPartnerAttributeCategoryTable.ColumnIndexId, btnDemoteCategory, btnPromoteCategory,
                delegate { FPetraUtilsObject.SetChangedFlag(); });

            // Hook up DataSavingStarted Event to be able to run code before SaveChanges is doing anything
            FPetraUtilsObject.DataSavingStarted += new TDataSavingStartHandler(DataSavingStarted);
            // We need to capture the 'DataSaved' event so we can save our Extra DataSet
            FPetraUtilsObject.DataSaved += new TDataSavedHandler(DataSaved);
            // We need to capture the 'NoMasterDataToSave' event so we can save our Extra DataSet
            // in case that no data was changed in this Forms' pnlDetails
            FPetraUtilsObject.NoMasterDataToSave += NoMasterDataToSave;

            // We also want to know if the UserControl holds no more detail records
            ucoValues.NoMoreDetailRecords += Uco_NoMoreDetailRecords;

            ucoValues.PetraUtilsObject = FPetraUtilsObject;

            grdDetails.Selection.FocusRowLeaving += HandleFocusRowLeaving;

            // We capture the Leave event of the Code TextBox (This is more consistent than LostFocus. - it always occurs
            // before validation, whereas LostFocus occurs before or after depending on mouse or keyboard.)
            txtDetailCategoryCode.Leave += new EventHandler(txtDetailCategoryCode_Leave);

            // Set up Timer that is needed for showing MessageBoxes from a Grid Event
            ShowMessageBoxTimer.Tick += new EventHandler(ShowTimerDrivenMessageBox);
            ShowMessageBoxTimer.Interval = 100;

            /* fix tab order */
            pnlButtons.TabIndex = grdDetails.TabIndex + 1;
        }
        private void RunOnceOnActivationManual()
        {
            // Set up the window title
            if (String.Compare(Context, "Bank", true) == 0)
            {
                this.Text += Catalog.GetString(" For Bank");
            }
            else if (String.Compare(Context, "Church", true) == 0)
            {
                this.Text += Catalog.GetString(" For Church");
            }
            else if (String.Compare(Context, "Family", true) == 0)
            {
                this.Text += Catalog.GetString(" For Family");
            }
            else if (String.Compare(Context, "Organisation", true) == 0)
            {
                this.Text += Catalog.GetString(" For Organisation");
            }
            else if (String.Compare(Context, "Person", true) == 0)
            {
                this.Text += Catalog.GetString(" For Person");
            }
            else if (String.Compare(Context, "Unit", true) == 0)
            {
                this.Text += Catalog.GetString(" For Unit");
            }
            else if (String.Compare(Context, "Venue", true) == 0)
            {
                this.Text += Catalog.GetString(" For Venue");
            }
            else if (String.Compare(Context, "LongTermApp", true) == 0)
            {
                this.Text += Catalog.GetString(" For Long Term Applications");
            }
            else if (String.Compare(Context, "ShortTermApp", true) == 0)
            {
                this.Text += Catalog.GetString(" For Short Term Applications");
            }
            else if (String.Compare(Context, "Personnel", true) == 0)
            {
                this.Text += Catalog.GetString(" For Personnel");
            }

            // Initialize 'Helper Class' for handling the Indexes of the DataRows.
            FIndexedGridRowsHelper = new TSgrdDataGrid.IndexedGridRowsHelper(
                grdDetails, PDataLabelUseTable.ColumnIdx1Id, btnDemote, btnPromote,
                delegate { FPetraUtilsObject.SetChangedFlag(); });

            // Load the Extra Data from DataLabel table
            Type DataTableType;
            FExtraDS.PDataLabel = new PDataLabelTable();
            DataTable CacheDT = TDataCache.GetCacheableDataTableFromCache("DataLabelList", String.Empty, null, out DataTableType);
            FExtraDS.PDataLabel.Merge(CacheDT);

            // Extend our main DataLabelUse table
            int NameOrdinal = FMainDS.PDataLabelUse.Columns.Add("Name", typeof(String)).Ordinal;
            int GroupOrdinal = FMainDS.PDataLabelUse.Columns.Add("GroupHeading", typeof(String)).Ordinal;
            int DescriptionOrdinal = FMainDS.PDataLabelUse.Columns.Add("Description", typeof(String)).Ordinal;

            // Take each row of our main dataset and populate the new columns with relevant data
            //   from the DataLabelUse table
            foreach (PDataLabelUseRow useRow in FMainDS.PDataLabelUse.Rows)
            {
                PDataLabelRow labelRow = (PDataLabelRow)FExtraDS.PDataLabel.Rows.Find(new object[] { useRow.DataLabelKey });
                useRow[NameOrdinal] = labelRow.Text;
                useRow[GroupOrdinal] = labelRow.Group;
                useRow[DescriptionOrdinal] = labelRow.Description;
            }

            // Add columns to the grid for the label details
            grdDetails.AddTextColumn(Catalog.GetString("Name"), FMainDS.PDataLabelUse.Columns[NameOrdinal]);
            grdDetails.AddTextColumn(Catalog.GetString("Group Heading"), FMainDS.PDataLabelUse.Columns[GroupOrdinal]);
            grdDetails.AddTextColumn(Catalog.GetString("Description"), FMainDS.PDataLabelUse.Columns[DescriptionOrdinal]);
            grdDetails.Selection.SelectionChanged += HandleSelectionChanged;

            // Remove the first column.  We added this in the YAML so that the auto-generator had something to do
            grdDetails.Columns.Remove(0);
            grdDetails.SetHeaderTooltip(0, Catalog.GetString("Name"));
            grdDetails.SetHeaderTooltip(1, Catalog.GetString("Group Heading"));
            grdDetails.SetHeaderTooltip(2, Catalog.GetString("Description"));

            // Create a view that will only show the rows applicable to our currentContext
            DataView contextView = new DataView(FMainDS.PDataLabelUse, "p_use_c='" + Context + "'", "p_idx1_i", DataViewRowState.CurrentRows);
            contextView.AllowNew = false;

            // Bind the view to our grid
            grdDetails.DataSource = new DevAge.ComponentModel.BoundDataView(contextView);
            grdDetails.Refresh();

            SelectRowInGrid(1);
        }
        private void InitializeManualCode()
        {
            // Initialize 'Helper Class' for handling the Indexes of the DataRows.
            FIndexedGridRowsHelper = new TSgrdDataGrid.IndexedGridRowsHelper(
                grdDetails, PPartnerAttributeTypeTable.ColumnIndexId, btnDemote, btnPromote,
                delegate { FPetraUtilsObject.SetChangedFlag(); });

            // Before we start we set the defaultView RowFilter property to something unlikely.
            // The manual code gets a chance to populate the grid before we get our chance to set the correct rowFilter.
            // So this ensures that the grid does not flicker with the wrong rows before we put the right ones in.
            string FilterStr = String.Format("{0}='@#~?!()'", FMainDS.PPartnerAttributeType.ColumnCategoryCode.ColumnName);

            FMainDS.PPartnerAttributeType.DefaultView.RowFilter = FilterStr;

            lblLinkFormatTip.Text = Catalog.GetString("Enter the URL that should be launched for the Contact Type ( e.g. http://www.facebook.com/" +
                THyperLinkHandling.HYPERLINK_WITH_VALUE_VALUE_PLACEHOLDER_IDENTIFIER + " ).");
            lblLinkFormatTip.Font = new System.Drawing.Font(lblLinkFormatTip.Font.FontFamily, 7, FontStyle.Regular);
            lblLinkFormatTip.Top -= 5;

            pnlDetails.MinimumSize = new Size(700, 145);              // To prevent shrinkage!

            /* fix tab order */
            pnlButtons.TabIndex = grdDetails.TabIndex + 1;
        }