We study the chemodynamical evolution of elliptical galaxies and their X-ray and optical properties using high-resolution cosmological simulations. Our tree N-body/smoothed particle hydrodynamics (SPH) code includes a self-consistent treatment of radiative cooling, star formation, supernovae feedback and chemical enrichment. We present a series of Λ cold dark matter (ΛCDM) cosmological simulations which trace the spatial and temporal evolution of abundances of heavy elements in both the stellar and gas components of galaxies. A giant elliptical galaxy formed in the simulations is quantitatively compared with the observational data in both the X-ray and optical regimes. X-ray spectra of the hot gas are constructed via the use of the VMEKAL plasma model, and analysed using XSPEC with the XMM European Photon Imaging Camera pn-CCD (EPN) response function. Optical properties are derived by the population synthesis for the stellar component. We find that radiative cooling is important to interpret the observed X-ray luminosity, temperature and metallicity of the hot gas of elliptical galaxies. However, this cooled gas also leads to excessive star formation at low redshift, and therefore results in underlying galactic stellar populations which are too blue with respect to observations. Time variation and radial dependence of X-ray properties and abundance ratios, such as [O/Fe] and [Si/Fe], of the X-ray-emitting hot gas are also discussed.