There is more than one way, but the easiest way to select all messages in a folder, even the ones not being displayed, is:
Control-Shift-A
You will see a temporary indication that all messages in the folder have been selected: