Esempio n. 1
0
        private void findAlbumOrSongToolStripMenuItem_Click(object sender, EventArgs e)
        {
            try
            {
                var findSong = new FindSong(true);
                var dialogResult = findSong.ShowDialog();

                //check to see if user completed the dialog box and therefore FoundGenres should not be null
                if (dialogResult == DialogResult.OK)
                {
                    //Clear datagrid to prevent any collisions
                    ClearDataGrid();
                    //sets datagrid to get information from the results of the findSong form
                    mainFormDataGridView.DataSource = findSong.FoundAlbumsAndSongs;
                    var titleHeaderIndex = 0;

                    //iterates through data headers
                    for (int i = 0; i < mainFormDataGridView.Columns.Count; i++)
                    {
                        //sets the header name to variable used later to check against
                        string columnHeaderName = mainFormDataGridView.Columns[i].HeaderText;

                        if (columnHeaderName == "ItemID")
                        {
                            //removes column from view and decrements i as the count is adjusted by the removal
                            mainFormDataGridView.Columns.Remove(columnHeaderName);
                            i--;
                        }

                        //gives extra space to title column
                        else if (columnHeaderName == "Title")
                            mainFormDataGridView.Columns[i].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;

                        else
                            //size column to fit around data in cells
                            mainFormDataGridView.Columns[i].AutoSizeMode = DataGridViewAutoSizeColumnMode.DisplayedCells;
                    }
                    viewToolStripMenuItem.Visible = true;
                }
            }
            catch (Exception ex)
            {
                DisplayErrorMessageBox(ex);
            }
        }
Esempio n. 2
0
        private void findSongToolStripMenuItem_Click(object sender, EventArgs e)
        {
            try
            {
                var findSong = new FindSong(false);
                var dialogResult = findSong.ShowDialog();

                //check to see if user completed the dialog box and therefore FoundGenres should not be null
                if (dialogResult == DialogResult.OK)
                {
                    //Clear datagrid to prevent any collisions
                    ClearDataGrid();
                    //sets datagrid to get information from the results of the findSong form
                    mainFormDataGridView.DataSource = findSong.FoundSongs;
                    UpdateDataGridForShowingSongData();
                }
            }
            catch (Exception ex)
            {
                DisplayErrorMessageBox(ex);
            }
        }