private void detailsContextMenuItem_Click(object sender, EventArgs e)
        {
            if ((gridPanel == null) || ( gridPanel.Selected_Row == null ) || ( gridPanel.Selected_Row.Length == 0 ))
                return;

            // Get first row then
            DataRow thisRow = gridPanel.Selected_Row[0];

            // Save the current size
            SMaRT_UserSettings.Item_Discovery_Form_Size = Size;
            SMaRT_UserSettings.Save();

            // Now, show the row
            View_Item_Group_Form showForm = new View_Item_Group_Form(thisRow);
            Hide();
            showForm.ShowDialog();
            Show();
        }
        void gridPanel_Double_Clicked(DataRow thisRow)
        {
            if (thisRow != null)
            {
                // What is the currently selected action?
                if (openItemGroupOnWebMenuItem.Checked)
                {
                    string bibid = thisRow["BibID"].ToString();
                    string vid = thisRow["VID"].ToString();
                    string url = SobekCM_Library_Settings.System_Base_URL + bibid;
                    if (vid.IndexOf("(") < 0)
                    {
                        url = url + "/" + vid;
                    }

                    try
                    {
                        Process openOnWeb = new Process {StartInfo = {FileName = url}};
                        openOnWeb.Start();
                    }
                    catch
                    {
                        MessageBox.Show("Error opening item group from the web.     ", "Browser Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                }
                else
                {
                    // Save the current size
                    SMaRT_UserSettings.Item_Discovery_Form_Size = Size;
                    SMaRT_UserSettings.Save();

                    // Now, show the row
                    View_Item_Group_Form showForm = new View_Item_Group_Form(thisRow);
                    Hide();
                    showForm.ShowDialog();
                    Show();
                }
            }
        }
        private void Show_Items(DataSet dataSet, string Code_for_browse)
        {
            database_dataset_to_tracking_bib_table(dataSet);

            if ((displayTable == null) || (displayTable.Rows.Count == 0))
            {
                if (gridPanel != null)
                {
                    mainPanel.Controls.Remove(gridPanel);
                    gridPanel = null;
                }
                Clear_Items(false);
                hitCountLabel.Text = "No Matches Found";
            }
            else
            {
                instructionLabel.Hide();
                if (gridPanel == null)
                {
                    gridPanel = new CustomGrid_Panel
                                    {
                                        Size = new Size(mainPanel.Width - 2, mainPanel.Height - 2),
                                        Location = new Point(0, 0)
                                    };

                    // Configure some table level style settings
                    gridPanel.Style.Default_Column_Width = 80;
                    gridPanel.Style.Default_Column_Color = Color.LightBlue;
                    gridPanel.Style.Header_Back_Color = Color.DarkBlue;
                    gridPanel.Style.Header_Fore_Color = Color.White;

                    //// initial the sort option
                    //if (this.Current_Sort_String.Length == 0)
                    //    this.Current_Sort_String = "BibID ASC";// Use the table from the database as the data source
                    //this.DataTable = sourceTable;

                    // Set the background and border style
                    gridPanel.BackColor = Color.WhiteSmoke;
                    gridPanel.BorderStyle = BorderStyle.FixedSingle;
                    gridPanel.Anchor = (((((AnchorStyles.Top | AnchorStyles.Bottom) | AnchorStyles.Left) | AnchorStyles.Right)));
                    mainPanel.Controls.Add(gridPanel);

                    // Add the event to the grid panel
                    gridPanel.Double_Clicked += gridPanel_Double_Clicked;
                    gridPanel.Clipboard_Copy_Requested +=new CustomGrid_Panel_Delegate_Multiple(gridPanel_Clipboard_Copy_Requested);

                    // Add the context menu
                    gridPanel.Set_Context_Menus(null, contextMenu1);

                    // Add the object to print
                    gridPrinter = new CustomGrid_Printer(gridPanel, printDocument1);
                }
                else
                {
                    // Save the column sizes
                    SMaRT_UserSettings.Discovery_Form_Title_Width = gridPanel.Style.Column_Styles[5].Width;
                    SMaRT_UserSettings.Discovery_Form_Author_Width = gridPanel.Style.Column_Styles[6].Width;
                    SMaRT_UserSettings.Discovery_Form_Publisher_Width = gridPanel.Style.Column_Styles[7].Width;
                }

                gridPanel.DataTable = displayTable;

                gridPanel.Current_Sort_String = "BibID ASC";

                // Configure for this table
                gridPanel.Style.Primary_Key_Column = 0;
                gridPanel.Style.Column_Styles[0].Visible = false;
                gridPanel.Style.Column_Styles[1].Fixed_Print_Width = 100;
                gridPanel.Style.Column_Styles[2].Width = 85;
                gridPanel.Style.Column_Styles[2].Fixed_Print_Width = 65;
                gridPanel.Style.Column_Styles[3].Fixed_Print_Width = 100;
                gridPanel.Style.Column_Styles[4].Fixed_Print_Width = 100;
                gridPanel.Style.Column_Styles[5].Width = SMaRT_UserSettings.Discovery_Form_Title_Width;
                gridPanel.Style.Column_Styles[5].Text_Alignment = HorizontalAlignment.Left;
                gridPanel.Style.Column_Styles[5].BackColor = Color.White;
                gridPanel.Style.Column_Styles[6].Width = SMaRT_UserSettings.Discovery_Form_Author_Width;
                gridPanel.Style.Column_Styles[6].Text_Alignment = HorizontalAlignment.Left;
                gridPanel.Style.Column_Styles[6].BackColor = Color.White;
                gridPanel.Style.Column_Styles[7].Width = SMaRT_UserSettings.Discovery_Form_Publisher_Width;
                gridPanel.Style.Column_Styles[7].Text_Alignment = HorizontalAlignment.Left;
                gridPanel.Style.Column_Styles[7].BackColor = Color.White;
                gridPanel.Style.Column_Styles[8].Width = 100;
                gridPanel.Style.Column_Styles[9].Width = 120;
                gridPanel.Style.Column_Styles[10].Visible = false;
                gridPanel.Style.Column_Styles[11].Visible = false;

                gridPanel.Style.Column_Styles[3].Ascending_Sort = "ALEPH ASC, BibID ASC";
                gridPanel.Style.Column_Styles[3].Descending_Sort = "ALEPH DESC, BibID DESC";

                gridPanel.Style.Column_Styles[4].Ascending_Sort = "OCLC ASC, BibID ASC";
                gridPanel.Style.Column_Styles[4].Descending_Sort = "OCLC DESC, BibID DESC";

                gridPanel.Style.Column_Styles[5].Ascending_Sort = "SortTitle ASC, BibID ASC";
                gridPanel.Style.Column_Styles[5].Descending_Sort = "SortTitle DESC, BibID DESC";

                gridPanel.Style.Column_Styles[8].Ascending_Sort = "Material_Type ASC, BibID ASC";
                gridPanel.Style.Column_Styles[8].Descending_Sort = "Material_Type DESC, BibID DESC";

                gridPanel.Style.Column_Styles[9].Ascending_Sort = "Aggregations ASC, BibID ASC";
                gridPanel.Style.Column_Styles[9].Descending_Sort = "Aggregations DESC, BibID DESC";

                if (Code_for_browse.Length > 0)
                {
                    switch (displayTable.Rows.Count)
                    {
                        case 1: hitCountLabel.Text = "Your browse resulted in one matching title"; break;
                        default: hitCountLabel.Text = "Your browse resulted in " + number_to_string(displayTable.Rows.Count) + " matching titles"; break;
                    }
                }
                else
                {
                    hitCountLabel.Text = "Your search resulted in " + number_to_string(itemCount) + " items in " + number_to_string(titleCount) + " titles";
                }

                // Determine if any ALEPH, OCLC, AUTHOR, or PUBLISHER data is present
                bool checkingAleph = true;
                bool checkingOclc = true;
                bool checkingAuthor = true;
                bool checkingPublisher = true;
                DataColumn alephColumn = displayTable.Columns["Aleph"];
                DataColumn oclcColumn = displayTable.Columns["OCLC"];
                DataColumn authorColumn = displayTable.Columns["Author"];
                DataColumn publisherColumn = displayTable.Columns["Publisher"];
                foreach (DataRow thisRow in displayTable.Rows)
                {
                    if (checkingAleph)
                    {
                        if (thisRow[alephColumn].ToString().Trim().Length > 0)
                        {
                            checkingAleph = false;
                        }
                    }

                    if (checkingOclc)
                    {
                        if (thisRow[oclcColumn].ToString().Trim().Length > 0)
                        {
                            checkingOclc = false;
                        }
                    }

                    if (checkingAuthor)
                    {
                        if (thisRow[authorColumn].ToString().Trim().Length > 0)
                        {
                            checkingAuthor = false;
                        }
                    }

                    if (checkingPublisher)
                    {
                        if (thisRow[publisherColumn].ToString().Trim().Length > 0)
                        {
                            checkingPublisher = false;
                        }
                    }

                    if ((!checkingAleph) && (!checkingAuthor) && (!checkingOclc) && (!checkingPublisher))
                        break;
                }

                // Set the visibility of the columns based on the data
                gridPanel.Style.Column_Styles[3].Visible = !checkingAleph;
                gridPanel.Style.Column_Styles[4].Visible = !checkingOclc;
                gridPanel.Style.Column_Styles[6].Visible = !checkingAuthor;
                gridPanel.Style.Column_Styles[7].Visible = !checkingPublisher;

                // Enable the menu items which are now applicable
                saveAsMenuItem.Enabled = true;
                printMenuItem.Enabled = true;
                printTrackingSheetsMenuItem.Enabled = true;
                editSerialHierarchyToolStripMenuItem.Enabled = true;
                viewAdHocReportMenuItem.Enabled = true;
                setTrackingBoxToolStripMenuItem.Enabled = true;
                editDispositionAdviceMenuItem.Enabled = true;
                updateItemDispositionMenuItem.Enabled = true;
                addWorklogHistoryEntryMenuItem.Enabled = true;
                updateBornDigitalFlagMenuItem.Enabled = true;
                updateMaterialReceivedDateMenuItem.Enabled = true;

                // Now, some final code if there was only one result
                if ((displayTable.Rows.Count == 1) && (SMaRT_UserSettings.Item_Discovery_Form_Single_Result_Action == Single_Result_Action_Enum.Show_Details_For_Single_Item))
                {
                    // What is the currently selected action?
                    if (openItemGroupOnWebMenuItem.Checked)
                    {
                        string bibid = displayTable.Rows[0]["BibID"].ToString();
                        string vid = displayTable.Rows[0]["VID"].ToString();
                        string url = SobekCM_Library_Settings.System_Base_URL+ bibid;
                        if (vid.IndexOf("(") < 0)
                        {
                            url = url + "/" + vid;
                        }

                        try
                        {
                            Process openOnWeb = new Process {StartInfo = {FileName = url}};
                            openOnWeb.Start();
                        }
                        catch
                        {
                            MessageBox.Show("Error opening item group from the web.     ", "Browser Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        }
                    }
                    else
                    {
                        // Save the current size
                        SMaRT_UserSettings.Item_Discovery_Form_Size = Size;
                        SMaRT_UserSettings.Save();

                        // Now, show the row
                        View_Item_Group_Form showForm = new View_Item_Group_Form(displayTable.Rows[0]);
                        Hide();
                        showForm.ShowDialog();
                        Show();
                    }
                }

                gridPanel.ReDraw();
                gridPanel.Focus();
            }
        }