ListBox delete row without losing position

I’ve got a custom FileListComponent, and I’m trying to delete one of the files without losing the scroll position (as happens on refresh()).

So far I have:


I also tried creating a method to hide a row fileListComponent.hideRow (fileListComponent.getSelectedRow (0));, but no joy.

    void hideRow (int index)
        deselectRow (index);
        getComponentForRowNumber (index)->setSize (getWidth(), 0); 
        getComponentForRowNumber (index)->setVisible (false);

Am I missing something obvious?

The ListBox base class of FileListComponent is marked public so would it not be possible to save the vertical position (ListBox::getVerticalPosition) before removing the row, followed by a call to setVerticalPosition after you’ve removed it.

1 Like

Thanks @fabian, that worked :slight_smile: