Index: ActiviteitenOpvolging/ActiviteitenOpvolging/grids/IMainForm.vb =================================================================== diff -u -r1682 -r1701 --- ActiviteitenOpvolging/ActiviteitenOpvolging/grids/IMainForm.vb (.../IMainForm.vb) (revision 1682) +++ ActiviteitenOpvolging/ActiviteitenOpvolging/grids/IMainForm.vb (.../IMainForm.vb) (revision 1701) @@ -6,4 +6,11 @@ ''' The index of the grid, 0 based ''' A list containing all work items Function GetWorkItems(gridNumber As Integer) As List(Of IWorkItem) + + ''' + ''' A different activity was selected in the grid. + ''' + ''' The activity. Nothing means no activity was selected. + ''' The number of the grid + sub ChangeSelectedActivity(activity As IActivity, gridNumber As Integer) End Interface Index: ActiviteitenOpvolging/ActiviteitenOpvolging/ActiviteitenOpvolging.vbproj =================================================================== diff -u -r1696 -r1701 --- ActiviteitenOpvolging/ActiviteitenOpvolging/ActiviteitenOpvolging.vbproj (.../ActiviteitenOpvolging.vbproj) (revision 1696) +++ ActiviteitenOpvolging/ActiviteitenOpvolging/ActiviteitenOpvolging.vbproj (.../ActiviteitenOpvolging.vbproj) (revision 1701) @@ -94,7 +94,7 @@ - + Index: ActiviteitenOpvolging/ActiviteitenOpvolging/ActiviteitenOpvolgingForm.vb =================================================================== diff -u -r1693 -r1701 --- ActiviteitenOpvolging/ActiviteitenOpvolging/ActiviteitenOpvolgingForm.vb (.../ActiviteitenOpvolgingForm.vb) (revision 1693) +++ ActiviteitenOpvolging/ActiviteitenOpvolging/ActiviteitenOpvolgingForm.vb (.../ActiviteitenOpvolgingForm.vb) (revision 1701) @@ -47,12 +47,28 @@ _userControls.Add(userControl) 'Add to layout panel. DatagridViewControlsFlowLayoutPanel.Controls.Add(userControl) + 'CLear selection on every data grid view. + ChangeSelectedActivity(Nothing, 0) Next End Sub ''' - Public Function GetWorkItems(gridNumber As Integer) As List(Of IWorkItem)Implements IMainForm.GetWorkItems + Public Function GetWorkItems(gridNumber As Integer) As List(Of IWorkItem) Implements IMainForm.GetWorkItems Return _workItemManager.GiveWorkItems(gridNumber) End Function + ''' + Public Sub ChangeSelectedActivity(activity As IActivity, gridNumber As Integer) Implements IMainForm.ChangeSelectedActivity + 'If the activity is Nothing, no activity was selected, meaning that everything should be cleared. + If activity Is Nothing Then + 'Clear selection for every grid user control. + _userControls.ForEach(Sub(userControl) userControl.RemoveSelection()) + Else + 'Clear selection of every grid except the one with the grid number. + For each control in _userControls + 'Remove selection from every other grid. + if not control.GridNumber = gridNumber Then control.RemoveSelection() + Next + End If + End Sub End Class FishEye: Tag 1701 refers to a dead (removed) revision in file `ActiviteitenOpvolging/ActiviteitenOpvolging/grids/IUserControl.vb'. FishEye: No comparison available. Pass `N' to diff? Index: ActiviteitenOpvolging/ActiviteitenOpvolging/grids/IDataGridUserControl.vb =================================================================== diff -u --- ActiviteitenOpvolging/ActiviteitenOpvolging/grids/IDataGridUserControl.vb (revision 0) +++ ActiviteitenOpvolging/ActiviteitenOpvolging/grids/IDataGridUserControl.vb (revision 1701) @@ -0,0 +1,12 @@ +Public Interface IDataGridUserControl + ''' + ''' Clears the selection from the datagrid. + ''' + sub RemoveSelection() + + ''' + ''' Access to the grid number. + ''' + ''' + ReadOnly Property GridNumber As Integer +End Interface Index: ActiviteitenOpvolging/ActiviteitenOpvolging/grids/DataGridViewUserControl.vb =================================================================== diff -u -r1700 -r1701 --- ActiviteitenOpvolging/ActiviteitenOpvolging/grids/DataGridViewUserControl.vb (.../DataGridViewUserControl.vb) (revision 1700) +++ ActiviteitenOpvolging/ActiviteitenOpvolging/grids/DataGridViewUserControl.vb (.../DataGridViewUserControl.vb) (revision 1701) @@ -3,8 +3,9 @@ Public Class DataGridViewUserControl Implements IDataGridUserControl Private ReadOnly _parentForm As IMainForm - Private ReadOnly _gridNumber As Integer + Public ReadOnly Property GridNumber As Integer Implements IDataGridUserControl.GridNumber + Sub New() ' This call is required by the designer. InitializeComponent() @@ -26,9 +27,14 @@ _parentForm = parentForm 'Grid number. - _gridNumber = gridNumber + Me.GridNumber = gridNumber End Sub + ''' + Public Sub RemoveSelection() Implements IDataGridUserControl.RemoveSelection + _WorkItemsDataGridView.ClearSelection() + End Sub + Private Sub DataGridViewUserControl_Load(sender As Object, e As EventArgs) Handles MyBase.Load Try 'Set back color and fore color. @@ -64,7 +70,7 @@ WorkItemsDataGridView.RowTemplate.Height = 30 'todo configureerbaar maken 'Set label. - GridLabel.Text = ConfigsLoader.GridLabelNames(_gridNumber) + GridLabel.Text = ConfigsLoader.GridLabelNames(GridNumber) 'Load the data. LoadData() @@ -112,7 +118,7 @@ ''' Update the header text and visibility of the static columns. ''' Private Sub UpdateStaticColumns() - Dim names = ConfigsLoader.GridColumnHeaderNames().Item(_gridNumber) + Dim names = ConfigsLoader.GridColumnHeaderNames().Item(GridNumber) For i = 0 To names.Count() - 1 'Fetch name. Dim headerText = names(i) @@ -136,7 +142,7 @@ ''' Private Sub LoadWorkItems() Try - _workItems = _parentForm.GetWorkItems(_gridNumber) + _workItems = _parentForm.GetWorkItems(GridNumber) Catch ex As Exception Throw New Exception($"Could not load work items.{vbNewLine}{ex.Message}") End Try @@ -306,8 +312,8 @@ 'Disable click on columns or cell that should not be clicked on. 'Check columns, only activity columns should be able to be clicked on. If Not WorkItemsDataGridView.Columns(WorkItemsDataGridView.CurrentCell.ColumnIndex).Name.Contains("ActivityColumn") Then - 'Column is not that of an activity. Remove selection. - WorkItemsDataGridView.ClearSelection() + 'Column is not that of an activity + _parentForm.ChangeSelectedActivity(Nothing, GridNumber) Return End If @@ -321,14 +327,16 @@ If activity.Status = ActivityStateEnum.Finished Or activity.Status = ActivityStateEnum.Zero Or activity.IsReadOnly Then - 'If equal to one of those, remove selection. - WorkItemsDataGridView.ClearSelection() + 'If equal to one of those, the selection is not valid. + _parentForm.ChangeSelectedActivity(Nothing, GridNumber) + Else + 'Selection was valid. + _parentForm.ChangeSelectedActivity(activity, GridNumber) End If Catch ex As Exception MessageBox.Show($"Could not select a cell in {Me.Name}.{vbNewLine}{ex.Message}", "An error occured...", MessageBoxButtons.OK, MessageBoxIcon.Error) 'Remove selection. WorkItemsDataGridView.ClearSelection() End Try End Sub - End Class