コード例 #1
0
        private void btnClearFrequencies_Click(object sender, EventArgs e)
        {
            TextBox[] frequencyTextBoxes = new TextBox[] {
                txtLettersLower, txtLettersUpper, txtDigits, txtDigitSymbols,
                txtEasySymbols, txtEasySymbolsShift, txtHardSymbols, txtHardSymbolsShift };

            if (frequencyTextBoxes.Where(tb => !string.IsNullOrEmpty(tb.Text) && readInt(tb) != 0).Count() > 0)
            {

                DialogResult dialogResult = MessageBox.Show("Are you sure you want to clear frequency TextBoxes?", "Question",
                                                            MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1);

                if (dialogResult == DialogResult.Yes)
                    foreach (TextBox textBox in frequencyTextBoxes)
                        textBox.Text = "";
            }
        }