diff --git a/src/generic/grid.cpp b/src/generic/grid.cpp index 464f3d2c7e..6bdad3143c 100644 --- a/src/generic/grid.cpp +++ b/src/generic/grid.cpp @@ -10515,7 +10515,7 @@ void wxGrid::DeselectRow(int row) wxCHECK_RET( row >= 0 && row < m_numRows, wxT("invalid row index") ); if ( m_selection ) - m_selection->DeselectBlock(wxGridBlockCoords(row, 0, row, m_numRows - 1)); + m_selection->DeselectBlock(wxGridBlockCoords(row, 0, row, m_numCols - 1)); } void wxGrid::DeselectCol(int col) @@ -10523,7 +10523,7 @@ void wxGrid::DeselectCol(int col) wxCHECK_RET( col >= 0 && col < m_numCols, wxT("invalid column index") ); if ( m_selection ) - m_selection->DeselectBlock(wxGridBlockCoords(0, col, m_numCols - 1, col)); + m_selection->DeselectBlock(wxGridBlockCoords(0, col, m_numRows - 1, col)); } void wxGrid::DeselectCell( int row, int col ) diff --git a/tests/controls/gridtest.cpp b/tests/controls/gridtest.cpp index 9429a76ac8..e0a8ff4732 100644 --- a/tests/controls/gridtest.cpp +++ b/tests/controls/gridtest.cpp @@ -560,11 +560,21 @@ TEST_CASE_METHOD(GridTestCase, "Grid::Selection", "[grid]") CHECK(m_grid->IsInSelection(9, 1)); CHECK(!m_grid->IsInSelection(3, 0)); - m_grid->SelectRow(4); + m_grid->SelectRow(4, true /* add to selection */); CHECK(m_grid->IsInSelection(4, 0)); CHECK(m_grid->IsInSelection(4, 1)); CHECK(!m_grid->IsInSelection(3, 0)); + + // Check that deselecting a row does deselect the cells in it, but leaves + // the other ones selected. + m_grid->DeselectRow(4); + CHECK(!m_grid->IsInSelection(4, 0)); + CHECK(!m_grid->IsInSelection(4, 1)); + CHECK(m_grid->IsInSelection(0, 1)); + + m_grid->DeselectCol(1); + CHECK(!m_grid->IsInSelection(0, 1)); } TEST_CASE_METHOD(GridTestCase, "Grid::SelectionRange", "[grid]")