-
Notifications
You must be signed in to change notification settings - Fork 213
Expand file tree
/
Copy pathMainForm.cs
More file actions
43 lines (38 loc) · 1.04 KB
/
MainForm.cs
File metadata and controls
43 lines (38 loc) · 1.04 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
namespace FirstWinFormsApp
{
public partial class MainForm : Form
{
public MainForm()
{
InitializeComponent();
}
private int _count = 0;
private void IncreaseCounterButton_Click(
object sender, EventArgs e)
{
_count++;
CounterLabel.Text = _count.ToString();
}
private void HideButtonCheckbox_CheckedChanged(
object sender, EventArgs e)
{
IncreaseCounterButton.Visible =
!IncreaseCounterButton.Visible;
bool isChecked = HideButtonCheckbox.Checked;
}
private void YearOfBirthTextBox_KeyPress(
object sender, KeyPressEventArgs e)
{
if(!IsValid(e.KeyChar))
{
e.Handled = true;
}
}
private bool IsValid(char keyChar)
{
return char.IsControl(keyChar) ||
(char.IsDigit(keyChar) &&
YearOfBirthTextBox.Text.Length < 4);
}
}
}