We allow free binging on Halloween night. Afterwards, we put the bags on a shelf, and take them down after each lunch and dinner, and each child can choose one item to eat. I don't put any restrictions on this-- you aren't required to eat a certain amount of your dinner, or anything like that. I'm not using the candy to bribe them to eat. Although the other night, DD1 declared that her stomach hurt, and refused to even come to the table for the meal, and then turned up a half hour later looking for her Halloween treat, and I refused her.
After about a week of this, we'll stop offering after lunch, and just offer after dinner, until the stuff is gone. In my experience, with the quantity they get (TOO MUCH), it lasts until right before Christmas, just in time for my mother to load them down with MORE CANDY.

I do go through the bags while they're sleeping, Halloween night, and remove the really objectionable stuff-- gum, for instance. And I remove from DS's bag anything with soy in it. I buy a few bags of stuff ahead of time that don't have soy, so that I can trade with him piece for piece so he doesn't feel like he's being robbed. Although this year, the girls mostly traded with stuff from their own bags, and the stuff I bought wound up in the back of the pantry.
It totally makes me cringe every time I see them eat the stuff. I work so hard the rest of the year to keep sugar out of the house. But I'm learning that I have to compromise with the culture a bit-- that its' fun, and that the tiny bit of candy each day is not the nutritional end of the world, with the rest of their diet being so healthy.
(This is the first year we haven't had a candy buyback program at our church. I miss it-- it was awesome. The kids brought in their candy, and the committee doing the project paid for it, 25 cents a piece, and the money went into the kids' UNICEF boxes, and the candy itself was used in a pinata at a party we throw for kids in a local homeless shelter.)