Only set the current display mode index if the mode is valid.