VB6 msFlexGrid Prevent Selection of Header after Deleting all Rows in the FlexGrid Control

The flexgrid control is a killer control but one of its flaws is that something is always selected in the control, meaning, there is always at least a single cell selected which causes that cells backcolor to be .BackColorSel and the forecolor to be .ForeColorSel .

This is not really a problem unless you delete ALL the rows of the flexgrid, except for the header row. This results in a really ugly look.

Here is a trick to make the flexgrids header row to not be selected when all the other rows have been deleted.

At the top of the module have two constants which will store the flexgrids selection forecolor and backcolor:

When you want to delete all the rows except for the header row:

Now the FlexGrid has just one row, the header row. When it comes time to add new rows, just switch the colors back