  We calculate the single-particle states of a two-dimensional electron gas
(2DEG) in a perpendicular quantizing magnetic field, which is periodic in one
direction of the electron layer. We discuss the modulation of the electron
density in this system and compare it with that of a 2DEG in a periodic
electrostatic potential. We take account of the induced potential within the
Hartree approximation, and calculate self-consistently the density fluctuations
and effective energy bands. The electrostatic effects on the spectrum depend
strongly on the temperature and on the ratio between the cyclotron radius $R_c$
and the length scale $a_{\delta\rho}$ of the density variations. We find that
$a_{\delta\rho}$ can be equal to the modulation period $a$, but also much
smaller. For $R_c \sim a_{\delta\rho}$ the spectrum in the vicinity of the
chemical potential remains essentially the same as in the noninteracting
system, while for $R_c \ll a_{\delta\rho}$ it may be drastically changed by the
Hartree potential: For noninteger filling factors the energy dispersion is
reduced, like in the case of an electrostatic modulation, whereas for
even-integer filling factors, on the contrary, the dispersion may be amplified.
