/// <summary>
        /// Set cmbYear's list to all of the years contained
        /// in our data's records.
        ///
        /// Save the old value, and if set_to_zero==false, reselect
        /// that value when done. If set_to_zero==true, select first
        /// element in list.
        /// </summary>
        /// <param name="set_to_zero"></param>
        private void PopulateYearCombo(bool set_to_zero = true)
        {
            // turn off combo box's IndexChanged event handler
            cmbYear.SelectedIndexChanged -= cmbYear_SelectedIndexChanged;
            // save "before" value:
            string old_value = cmbYear.Text;

            cmbYear.DataSource = FileListManager.YearsInFileList();
            if (set_to_zero)
            {
                if (cmbYear.Items.Count > 0)
                {
                    cmbYear.SelectedIndex = 0;
                }
            }
            else
            {
                // Restore to old value, if that value still exists in the list.
                // If not, set to first value
                int idx = cmbYear.FindStringExact(old_value);
                if (idx == -1) // not found
                {
                    if (cmbYear.Items.Count > 0)
                    {
                        cmbYear.SelectedIndex = 0;
                    }
                }
                else
                {
                    cmbYear.SelectedIndex = idx;
                }
            }
            // turn IndexChanged event handler back on
            cmbYear.SelectedIndexChanged += cmbYear_SelectedIndexChanged;
        }
 /// <summary>
 /// Gray out buttons which aren't relevant.
 /// </summary>
 private void SetButtons()
 {
     // Show Delete BU btn if there are backup files to delete:
     btnDeleteBackups.Enabled = flm.HasBackupFiles;
     // We can't delete latest year's files -- don't show this
     // button unless there are some years we can delete from:
     btnDeleteOld.Enabled = flm.YearsInFileList().Count() > 0;
 }
Exemple #3
0
 private void SetLists()
 {
     this.lbxYears.DataSource   = _flm.YearsInFileList();
     this.lbxDocType.DataSource = Properties.Resources.DocumentTypesValues.Split('#');
 }