private void SetControls() { this.saveButton.Enabled = false; ToolTip tip = new ToolTip(); photos = new Photo(); foreach (Control control in Controls) { if (control is TextBox) { TextBox textBox = control as TextBox; textBox.TextChanged += TextChangedHandler; textBox.MouseDown += MouseDownHandler; labelMistake.AddMistakeLabel(textBox); } if (control is ComboBox) { ComboBox comboBox = control as ComboBox; comboBox.MouseDown += ComboBox_MouseDown; comboBox.SelectionChangeCommitted += ComboBox_SelectionChangeCommitted; comboBox.TextUpdate += ComboBox_TextUpdate; comboBox.TextChanged += ComboBox_TextChanged; labelMistake.AddMistakeLabel(comboBox); } if (control is PictureBox) { PictureBox pB = control as PictureBox; pB.MouseClick += PictureBox_MouseClickHandler; pB.Click += PictureBox_ClickHandler; pB.Paint += PictureBox_PaintHandler; } if (control is Label) { tip.SetToolTip(control, control.Tag.ToString()); } if (control is CustomProgressBar) { CustomProgressBar progressBar = control as CustomProgressBar; progressBar.Maximum = 100; tip.SetToolTip(progressBar, "Прогресс заполнения анкеты"); } if (control is MonthCalendar) { MonthCalendar monthCalendar = control as MonthCalendar; labelMistake.AddMistakeLabel(monthCalendar); //начальное состояние календаря monthCalendar.Tag = monthCalendar.SelectionRange.ToString(); } } }
private void progressBar1_ChangeValue(object sender, EventArgs e) { CustomProgressBar progressBar = sender as CustomProgressBar; if (progressBar.Value == 100) { this.saveButton.Enabled = true; } else { this.saveButton.Enabled = false; } }