To elucidate the relationship between the structure of ionic liquid (IL) and its enrichment ability to trace pesticides from an environmental water sample, a series of imidazole-based ILs were synthesized to extract four fungicides (boscalid, cyprodinil, fluazinam, and pyrimethanil) through an in situ ionic liquid dispersive liquid-liquid microextraction method. The results showed that aromatic heterocyclic monocation ionic liquids (MILs) had better extraction ability to fungicides than other three alicyclic heterocyclic MILs. Dication ionic liquids (DILs) with the four carbons at the side chain had better ability to extract fungicides than MILs, and DILs with a long bridge carbon chain had better recoveries of fungicides with low Kow values. The proposed method showed high mean enrichment factors and high recoveries of the fungicides from real water samples. The rules of the relationship between the structure of IL and enrichment ability are instructive to the application of ILs in pretreatment of complex substances.