The ions in a solid ionic compound are not randomly arranged. Instead, they have a regular, repeating arrangement called an ionic lattice. The lattice is formed because the ions attract each other and form a regular pattern with oppositely charged ions next to each other.
Remember that the lattice arrangement is giant - for example, a single grain of salt may contain 1.2 × 1018 (1,200,000,000,000,000,000) ions. The lattice arrangement continues in three dimensions. This is why solid ionic compounds form crystals with regular shapes.
The ionic lattice is held together by ionic bonds. In three-dimensional models, ionic bonds are shown as straight lines between ions. This is to keep things simple because ionic bonds can act in any direction.
Ionic bonds are strong electrostatic forces between oppositely charged ions.