-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathForm1.cs
More file actions
44 lines (40 loc) · 1.46 KB
/
Form1.cs
File metadata and controls
44 lines (40 loc) · 1.46 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
44
namespace StudentApp
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
// Delete Button
private void button3_Click(object sender, EventArgs e)
{
var userResponse = MessageBox.Show("Are you sure you want to delete?", "WARNING", MessageBoxButtons.YesNo, MessageBoxIcon.Warning);
if (userResponse == DialogResult.Yes)
{
MessageBox.Show($"Student: {Data.students.ElementAt(studentGrid.CurrentRow.Index).Lname} has been removed!");// has to come before removal because it will show the index beneath it
Data.students.RemoveAt(studentGrid.CurrentRow.Index);
studentGrid.DataSource = null;
studentGrid.DataSource = Data.students;// refresh
}
}
private void studentGrid_CellContentClick(object sender, DataGridViewCellEventArgs e)
{
}
// When the form loads do this...
private void Form1_Load(object sender, EventArgs e)
{
studentGrid.DataSource = Data.students;
}
private void btnRefresh_Click(object sender, EventArgs e)
{
studentGrid.DataSource = null;
studentGrid.DataSource = Data.students;
}
private void btnAdd_Click(object sender, EventArgs e)
{
AddForm addForm = new AddForm();
addForm.ShowDialog();
}
}
}