Context. Uranus and Neptune have atmospheres dominated by molecular hydrogen and helium. In the upper troposphere (between 0.1 and 10 bar), methane is the third main molecule, and it condenses, yielding a vertical gradient in CH4 . As this condensable species is heavier than H2 and He, the resulting change in mean molecular weight due to condensation serves as a factor countering convection, which is traditionally considered as governed by temperature only. This change in mean molecular weight makes both dry and moist convection more difficult to start. As observations also show latitudinal variations in methane abundance, one can expect different vertical gradients from one latitude to another. Aims. In this paper, we investigate the impact of this vertical gradient of methane and the different shapes it can take, including on the atmospheric regimes and especially on the formation and inhibition of moist convective storms in the troposphere of ice giants. Methods. We developed a 3D cloud-resolving model to simulate convective processes at the required scale. This model is nonhydrostatic and includes the effect of the mean molecular weight variations associated with condensation. Results. Using our simulations, we conclude that typical velocities of dry convection in the deep atmosphere are rather low (on the order of 1 m/s) but sufficient to sustain upward methane transport and that moist convection at the methane condensation level is strongly inhibited. Previous studies derived an analytical criterion on the methane vapor amount above which moist convection should be inhibited in saturated environments. In ice giants, this criterion yields a critical methane abundance of 1.2% at 80 K (this corresponds approximately to the 1 bar level). We first validated this analytical criterion numerically. We then showed that this critical methane abundance governs the inhibition and formation of moist convective storms, and we conclude that the intensity and intermittency of these storms should depend on the methane abundance and saturation. In the regions where CH4 exceeds this critical abundance in the deep atmosphere (at the equator and the middle latitudes on Uranus and at all latitudes on Neptune), a stable layer almost entirely saturated with methane develops at the condensation level. In this layer, moist convection is inhibited, ensuring stability. Only weak moist convective events can occur above this layer, where methane abundance becomes lower than the critical value. The inhibition of moist convection prevents strong drying and maintains high relative humidity, which favors the frequency of these events. In the regions where CH4 remains below this critical abundance in the deep atmosphere (possibly at the poles on Uranus), there is no such layer. More powerful storms can form, but they are also a bit rarer. Conclusions. In ice giants, dry convection is weak, and moist convection is strongly inhibited. However, when enough methane is transported upward, through dry convection and turbulent diffusion, sporadic moist convective storms can form. These storms should be more frequent on Neptune than on Uranus because of Neptune’s internal heat flow and larger methane abundance. Our results can explain the observed sporadicity of clouds in ice giants and help guide future observations that can test the conclusions of this work.