We simulate the formation and chemodynamical evolution of 124 elliptical galaxies by using a GRAPE-SPH code that includes various physical processes associated with the formation of stellar systems : radiative cooling , star formation , feedback from Type II and Ia supernovae and stellar winds , and chemical enrichment . In our CDM-based scenario , galaxies form through the successive merging of sub-galaxies with various masses . Their merging histories vary between a major merger at one extreme , and a monolithic collapse of a slow-rotating gas cloud at the other extreme . We examine the physical conditions during 151 merging events that occur in our simulation . The basic processes driving the evolution of the metallicity gradients are as follows : i ) destruction by mergers to an extent dependent on the progenitor mass ratio . ii ) regeneration when strong central star formation is induced at a rate dependent on the gas mass of the secondary . iii ) slow evolution as star formation is induced in the outer regions through late gas accretion . We succeed in reproducing the observed variety of the radial metallicity gradients . The average metallicity gradient \Delta \log Z / \Delta \log r \simeq - 0.3 with dispersion of \pm 0.2 and no correlation between gradient and galaxy mass are consistent with observations of Mg _ { 2 } gradients . The variety of the gradients stems from the difference in the merging histories . Galaxies that form monolithically have steeper gradients , while galaxies that undergo major mergers have shallower gradients . Thus merging histories can , in principle , be inferred from the observed metallicity gradients of present-day galaxies . The observed variation in the metallicity gradients can not be explained by either monolithic collapse or by major merger alone . Rather it requires a model in which both formation processes arise , such as the present CDM scheme .