Fix crash when checkbox checked via spacebar.
This commit is contained in:
parent
76cb280933
commit
d2892f9076
@ -7,6 +7,7 @@ using System.Linq;
|
||||
using System.Windows.Forms;
|
||||
using ApplicationServices;
|
||||
using DataLayer;
|
||||
using Dinah.Core.Threading;
|
||||
using Dinah.Core.DataBinding;
|
||||
using InternalUtilities;
|
||||
using LibationWinForms.Login;
|
||||
@ -32,9 +33,8 @@ namespace LibationWinForms.Dialogs
|
||||
InitializeComponent();
|
||||
_labelFormat = label1.Text;
|
||||
|
||||
_dataGridView.CellContentClick += (s, e) => _dataGridView.CommitEdit(DataGridViewDataErrorContexts.Commit);
|
||||
_dataGridView.CellValueChanged += DataGridView1_CellValueChanged;
|
||||
_dataGridView.BindingContextChanged += (s, e) => UpdateSelection();
|
||||
_dataGridView.CellContentClick +=(s,e) => _dataGridView.CommitEdit(DataGridViewDataErrorContexts.Commit);
|
||||
_dataGridView.BindingContextChanged += _dataGridView_BindingContextChanged;
|
||||
|
||||
var orderedGridEntries = _libraryBooks
|
||||
.Select(lb => new RemovableGridEntry(lb))
|
||||
@ -47,10 +47,10 @@ namespace LibationWinForms.Dialogs
|
||||
_dataGridView.Enabled = false;
|
||||
}
|
||||
|
||||
private void DataGridView1_CellValueChanged(object sender, DataGridViewCellEventArgs e)
|
||||
private void _dataGridView_BindingContextChanged(object sender, EventArgs e)
|
||||
{
|
||||
if (e.ColumnIndex == 0)
|
||||
UpdateSelection();
|
||||
_dataGridView.Sort(_dataGridView.Columns[0], ListSortDirection.Descending);
|
||||
UpdateSelection();
|
||||
}
|
||||
|
||||
private async void RemoveBooksDialog_Shown(object sender, EventArgs e)
|
||||
@ -124,7 +124,6 @@ namespace LibationWinForms.Dialogs
|
||||
}
|
||||
private void UpdateSelection()
|
||||
{
|
||||
_dataGridView.Sort(_dataGridView.Columns[0], ListSortDirection.Descending);
|
||||
var selectedCount = SelectedCount;
|
||||
label1.Text = string.Format(_labelFormat, selectedCount, selectedCount != 1 ? "s" : string.Empty);
|
||||
btnRemoveBooks.Enabled = selectedCount > 0;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user