private void ConfigureViewForm_Load(object sender, EventArgs e) { // Suspend the layout logic for the issues and tasks DataGridView, while initializing GridIssues.SuspendLayout(); GridTasks.SuspendLayout(); // Initialization of the Issues and Tasks grids InitializeGridIssues(); InitializeGridTasks(); // Populate the Issues and Tasks grids PopulateGridIssues(); PopulateGridTasks(); // Resume the layout logic GridTasks.ResumeLayout(); GridIssues.ResumeLayout(); SetAccessibilityInformation(); }
/// <summary> /// Handle clicks on the checkboxes of the issues DataGridView. /// </summary> private void GridIssues_CellContentClick(object sender, DataGridViewCellEventArgs e) { bool flagClickSort = false; // Control the visibility of columns (the visibility of the ID column cannot be modified) if ((e.ColumnIndex == GridIssues.Columns["visible"].Index) && (e.RowIndex > 0)) { // If the user hides a column, then uncheck the sort checkboxes and disable them if (!Boolean.Parse(GridIssues["visible", e.RowIndex].EditedFormattedValue.ToString())) { GridIssues["sort1", e.RowIndex].Value = false; GridIssues["sort1", e.RowIndex].ReadOnly = true; GridIssues["sort2", e.RowIndex].Value = false; GridIssues["sort2", e.RowIndex].ReadOnly = true; GridIssues["sortOrder", e.RowIndex].Value = string.Empty; GridIssues["sortOrder", e.RowIndex].ReadOnly = true; } else { // Re-enable the sort checkboxes because the column is visible again GridIssues["sort1", e.RowIndex].ReadOnly = false; GridIssues["sort2", e.RowIndex].ReadOnly = false; } GridIssues.Refresh(); } else if ((e.ColumnIndex == GridIssues.Columns["sort1"].Index) && (e.RowIndex != -1)) { // Only change the controls state if the cell is not readonly if (!GridIssues["sort1", e.RowIndex].ReadOnly) { if (Boolean.Parse(GridIssues["sort1", e.RowIndex].EditedFormattedValue.ToString())) { GridIssues["sort2", e.RowIndex].Value = false; // Uncheck any other fields in the same column for (int i = 0; i < GridIssues.Rows.Count; ++i) { if (i != e.RowIndex) { if (Boolean.Parse(GridIssues["sort1", i].Value.ToString())) { GridIssues["sort1", i].Value = false; GridIssues["sortOrder", i].Value = string.Empty; } } } // Enable the sort order combobox GridIssues["sortOrder", e.RowIndex].ReadOnly = false; GridIssues["sortOrder", e.RowIndex].Value = "Ascending"; } // Signal that the user clicked on one of the sort checkboxes flagClickSort = true; } } else if ((e.ColumnIndex == GridIssues.Columns["sort2"].Index) && (e.RowIndex != -1)) { // Only change the controls state if the cell is not readonly if (!GridIssues["sort2", e.RowIndex].ReadOnly) { if (Boolean.Parse(GridIssues["visible", e.RowIndex].EditedFormattedValue.ToString())) { GridIssues["sort1", e.RowIndex].Value = false; // Uncheck any other fields in the same column for (int i = 0; i < GridIssues.Rows.Count; ++i) { if (i != e.RowIndex) { if (Boolean.Parse(GridIssues["sort2", i].Value.ToString())) { GridIssues["sort2", i].Value = false; GridIssues["sortOrder", i].Value = string.Empty; } } } // Enable the sort order combobox GridIssues["sortOrder", e.RowIndex].ReadOnly = false; GridIssues["sortOrder", e.RowIndex].Value = "Ascending"; } // Signal that the user clicked on one of the sort checkboxes flagClickSort = true; } } // If the user unchecked both sort checkboxes if ((flagClickSort) && ((!Boolean.Parse(GridIssues["sort1", e.RowIndex].EditedFormattedValue.ToString())) && (!Boolean.Parse(GridIssues["sort2", e.RowIndex].EditedFormattedValue.ToString())))) { GridIssues["sortOrder", e.RowIndex].ReadOnly = true; GridIssues["sortOrder", e.RowIndex].Value = string.Empty; } }