H.S.
I was going through this about a month ago with my 4 year old. Now every time I catch him I tell him (very matter of factly) that he has a choice to make here. He could go ahead and eat the ice cream in witch case I would throw away whatever he did not eat and not buy any more for 4 weeks (1 week for each year of age), or he could put the ice cream away and be able to eat some after he finishes his dinner. My son chose to eat the ice cream the first time but after a month of no ice cream and me reminding him why there was no ice cream in the house, he stopped trying to sneak it.
I beleive that one of the best things we can teach our children is patience and this is just one of the many ways to do that.
I hope this helps!
H. Stanley