A codebook based adaptive beamforming switching scheme and a throughput based selective algorithm are proposed for 5G rail communications systems. The goal is to enhance the transmission capacity within the cell range of a trackside basestation. The main idea is to implement a Dual-Transmitter Dual-Receiver (DTDR) model transmitted with dual-beam to achieve higher capacity as the train is approaching the basestation, and switch to the Single-Transmitter Single-Receiver (STSR) model using single beam when the train is far away from the basestation to avoid the degradation of capacity caused by interference. This switching scheme benefits from space multiplexing using dual-beam transmission whilst avoiding inter-beam interference by switching to the single-beam transmission. Based on this new scheme, a novel selective algorithm is proposed to further enhance the system performance. The numerical results show that, for high-speed railway communications under parameters and environment given in this paper, the switching scheme achieves 52% higher capacity than using the STSR model or 35% higher than using the DTDR model, where codebook beamforming technique is adopted at the transmitter, and 36% higher capacity of the system is realized by using the selective algorithm compared with the original one.