export button now only available if any user is selected

This commit is contained in:
Blauschleim
2022-05-16 19:49:37 +02:00
parent 961a5274cf
commit ad382764b6
2 changed files with 34 additions and 2 deletions

3
Form1.Designer.cs generated
View File

@@ -60,6 +60,7 @@ namespace it_projekt
// //
// exportBtn // exportBtn
// //
this.exportBtn.Enabled = false;
this.exportBtn.Location = new System.Drawing.Point(480, 80); this.exportBtn.Location = new System.Drawing.Point(480, 80);
this.exportBtn.Name = "exportBtn"; this.exportBtn.Name = "exportBtn";
this.exportBtn.Size = new System.Drawing.Size(75, 23); this.exportBtn.Size = new System.Drawing.Size(75, 23);
@@ -119,7 +120,7 @@ namespace it_projekt
this.dataGrid.RowTemplate.Height = 25; this.dataGrid.RowTemplate.Height = 25;
this.dataGrid.Size = new System.Drawing.Size(743, 225); this.dataGrid.Size = new System.Drawing.Size(743, 225);
this.dataGrid.TabIndex = 7; this.dataGrid.TabIndex = 7;
this.dataGrid.CellContentClick += new System.Windows.Forms.DataGridViewCellEventHandler(this.dataGrid_CellContentClick); this.dataGrid.CellContentClick += new System.Windows.Forms.DataGridViewCellEventHandler(this.DataGridView_CellClick);
// //
// Id // Id
// //

View File

@@ -48,13 +48,18 @@ namespace it_projekt
this.dataGrid.Rows.Add(person.Id, person.Firstname, person.Lastname, person.Department_short, person.Department_long, person.CreationDate, false); this.dataGrid.Rows.Add(person.Id, person.Firstname, person.Lastname, person.Department_short, person.Department_long, person.CreationDate, false);
} }
this.loginBtn.Enabled = false; this.loginBtn.Enabled = false;
this.exportBtn.Enabled = true;
} }
} }
private void dataGrid_CellContentClick(object sender, DataGridViewCellEventArgs e) private void dataGrid_CellContentClick(object sender, DataGridViewCellEventArgs e)
{ {
}
private System.EventHandler test()
{
this.exportBtn.Enabled = false;
return null;
} }
private void export(string Filter, string FileName) private void export(string Filter, string FileName)
@@ -120,5 +125,31 @@ namespace it_projekt
{ {
} }
private void DataGridView_CellClick(object sender, DataGridViewCellEventArgs e)
{
//Check to ensure that the row CheckBox is clicked.
if (e.RowIndex >= 0 && e.ColumnIndex == 6)
{
//Reference the GridView Row.
DataGridViewRow row = dataGrid.Rows[e.RowIndex];
//Set the CheckBox selection.
row.Cells[6].Value = Convert.ToBoolean(row.Cells[6].EditedFormattedValue);
exportBtn.Enabled = false;
//If CheckBox is checked, display Message Box.
if (Convert.ToBoolean(row.Cells[6].Value))
{
exportBtn.Enabled = true;
}
foreach (DataGridViewRow r in dataGrid.Rows)
{
if (Convert.ToBoolean(r.Cells[6].Value))
{
exportBtn.Enabled = true;
}
}
}
}
} }
} }