/// <summary>
        /// search for the partners with the currently entered criteria
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        public void BtnSearch_Click(System.Object sender, System.EventArgs e)
        {
//            TLogging.Log("BtnSearch_Click: FKeepUpSearchFinishedCheck = " + FKeepUpSearchFinishedCheck.ToString());
            if (!FKeepUpSearchFinishedCheck)
            {
                FPartnerInfoUC = ((TUC_PartnerInfo)(ucoPartnerInfo.UserControlInstance));

                // get the data from the currently edited control;
                // otherwise there are not the right search criteria when hitting the enter key
                ucoPartnerFindCriteria.CompleteBindings();

                FCriteriaData = ucoPartnerFindCriteria.CriteriaData;

                if (!ucoPartnerFindCriteria.HasSearchCriteria())
                {
                    string TitleBar = string.Empty;

                    if (FBankDetailsTab)
                    {
                        TitleBar = Catalog.GetString("Find by Bank Details");
                    }
                    else
                    {
                        TitleBar = Catalog.GetString("Find by Partner Details");
                    }

                    MessageBox.Show(MPartnerResourcestrings.StrNoCriteriaSpecified, TitleBar, MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    return;
                }

                ucoPartnerFindCriteria.CriteriaData.Rows[0]["ExactPartnerKeyMatch"] = TUserDefaults.GetBooleanDefault(
                    TUserDefaults.PARTNER_FINDOPTIONS_EXACTPARTNERKEYMATCHSEARCH,
                    true);

                CreateGrid();

                // Update UI
                grpResult.Text = MPartnerResourcestrings.StrSearchResult;

                if (FPartnerInfoUC != null)
                {
                    FPartnerInfoUC.ClearControls();
                }

                lblSearchInfo.Text = MPartnerResourcestrings.StrSearching;
                FPetraUtilsObject.SetStatusBarText(btnSearch, MPartnerResourcestrings.StrSearching);

                //                stbMain.Panels[stbMain.Panels.IndexOf(stpInfo)].Text = Resourcestrings.StrSearching;

                this.Cursor = Cursors.AppStarting;
                FKeepUpSearchFinishedCheck = true;
                EnableDisableUI(false);

                // DoEvents() should not be run if search has been initiated by pressing the enter key
                KeyEventArgs eTemp = e as KeyEventArgs;

                if ((eTemp == null) || (eTemp.KeyCode != Keys.Enter))
                {
                    Application.DoEvents();
                }

/*
 *              // If ctrl held down, show the dataset
 *              if (System.Windows.Forms.Form.ModifierKeys == Keys.Control)
 *              {
 *                  MessageBox.Show(ucoPartnerFindCriteria.CriteriaData.DataSet.GetXml().ToString());
 *                  MessageBox.Show(ucoPartnerFindCriteria.CriteriaData.DataSet.GetChanges().GetXml().ToString());
 *              }
 */
                // Clear result table
                try
                {
                    if (FPagedDataTable != null)
                    {
                        FPagedDataTable.Clear();
                    }
                }
                catch (Exception)
                {
                    // don't do anything since this happens if the DataTable has no data yet
                }

                // Reset internal status variables
                FLastSearchWasDetailedSearch = chkDetailedResults.Checked;

                if (chkDetailedResults.Checked)
                {
                    FResultListIncludesDetailedResultColumns = 2;
                }
                else
                {
                    FResultListIncludesDetailedResultColumns = 1;
                }

                FCriteriaContentChanged = false;
                FLogic.ResetLastPartnerDataInfoPanel();

                // Start asynchronous search operation
                this.PerformSearch();
            }
            else
            {
//TLogging.Log("Asynchronous search operation is being interrupted!");
                // Asynchronous search operation is being interrupted
                btnSearch.Enabled = false;
                lblSearchInfo.Text = MPartnerResourcestrings.StrStoppingSearch;
                FPetraUtilsObject.WriteToStatusBar(MPartnerResourcestrings.StrStoppingSearch);
                FPetraUtilsObject.SetStatusBarText(btnSearch, MPartnerResourcestrings.StrStoppingSearch);

                Application.DoEvents();

                // Stop asynchronous search operation
                FPartnerFindObject.StopSearch();
            }
        }
        private void OpenPartnerInfoPane(bool AUserControlIsArleadyExpanded = false)
        {
            OnPartnerInfoPaneExpanded();

            if (!AUserControlIsArleadyExpanded)
            {
                ucoPartnerInfo.Expand();
            }

            if (FPartnerInfoUC == null)
            {
                FPartnerInfoUC = ((TUC_PartnerInfo)(ucoPartnerInfo.UserControlInstance));
                FPartnerInfoUC.PetraUtilsObject = FPetraUtilsObject;
                FPartnerInfoUC.InitUserControl();
            }

            UpdatePartnerInfoPanel();

            //            MessageBox.Show("FCurrentGridRow: " + FCurrentGridRow.ToString());
            if (FCurrentGridRow != -1)
            {
                // Scroll the selected Row into view
                // FIXME: this has an undesired side-effect if the selected Row is not hidden
                // behind the Partner Info pane, but is scrolled off the top of the Grid.
                //                bool CellWasVisible = grdResult.ShowCell(new Position(FCurrentGridRow, 0), false);

                /*
                 * TODO: Ideally. we would not have row displayed as the top row, but the bottm row.
                 * The approach below works - unless grdResult.ShowCell didn't put the row as the
                 * top row. No solution to that yet...
                 */

                //                if (!CellWasVisible)
                //                {
                //                    // Scrolling was necessary. Now the Row is displayed as the top row,
                //                    // but we want it to be displayed as the middle row. Therefore we need
                //                    // to scroll the Grid up until it is the middle row...
                ////                    MessageBox.Show("Scrolled FCurrentGridRow: " + FCurrentGridRow.ToString() + " into view.");
//
                //                    int ScrollAdditionalRows = (grdResult.Rows.LastVisibleScrollableRow.Value -
                //                        grdResult.Rows.FirstVisibleScrollableRow.Value) / 2;
                //                    MessageBox.Show("ScrollAdditionalRows: " + ScrollAdditionalRows.ToString());
//
                //                    for (int Counter = 1; Counter < ScrollAdditionalRows; Counter++)
                //                    {
                ////                        MessageBox.Show("about to scroll one line up...");
                //                        grdResult.CustomScrollLineUp();
                //                    }
                //                }
            }

            FPartnerInfoPaneOpen = true;
        }
        /// <summary>
        /// Causes the 'Partner Info' UserControl to update itself.
        /// </summary>
        /// <param name="ALocationDataAvailable">Set to true if Location data is available.</param>
        /// <param name="APartnerInfoUC">Instance of the PartnerInfo UserControl</param>
        /// <returns>True if an 'update' was done, false if the Partner Info Control already had current data and hence no
        /// update was done.</returns>
        public bool UpdatePartnerInfoPanel(bool ALocationDataAvailable, TUC_PartnerInfo APartnerInfoUC)
        {
            bool ReturnValue = false;
            TLocationPK CurrentLocationPK;

            CurrentLocationPK = DetermineCurrentLocationPK();

            //                MessageBox.Show("Current PartnerKey: " + PartnerKey.ToString() + Environment.NewLine +
            //                                "FLastPartnerKeyInfoPanelOpened: " + FLastPartnerKeyInfoPanelOpened.ToString() + Environment.NewLine +
            //                                "CurrentLocationPK: " + CurrentLocationPK.SiteKey.ToString() + ", " + CurrentLocationPK.LocationKey.ToString() + Environment.NewLine +
            //                                "FLastLocationPKInfoPanelOpened: " + FLastLocationPKInfoPanelOpened.SiteKey.ToString() + ", " + FLastLocationPKInfoPanelOpened.LocationKey.ToString());
            if ((CurrentDataRow != null)
                && (((FLastPartnerKeyInfoPanelOpened == PartnerKey)
                     && ((FLastLocationPKInfoPanelOpened.SiteKey != CurrentLocationPK.SiteKey)
                         || (FLastLocationPKInfoPanelOpened.LocationKey != CurrentLocationPK.LocationKey)))
                    || (FLastPartnerKeyInfoPanelOpened != PartnerKey)))
            {
                FLastPartnerKeyInfoPanelOpened = PartnerKey;
                FLastLocationPKInfoPanelOpened = CurrentLocationPK;

                if (ALocationDataAvailable)
                {
                    // We have Location data available
                    APartnerInfoUC.PassPartnerDataPartialWithLocation(PartnerKey, CurrentDataRow);
                }
                else
                {
                    // We don't have Location data available
                    APartnerInfoUC.PassPartnerDataPartialWithoutLocation(PartnerKey, CurrentDataRow);
                }

                ReturnValue = true;
            }

            return ReturnValue;
        }