Bringing something you can eat is the best thing you can do. Not going there hungry is another great advice.
If you're going to a BBQ, there is always the lovely '"meat+vegetable" option. No bread, no potatoes. And apetizers are just, well, not necessary I think
There are, however, situations when I can not avoid eating something not very good for my diet. Or I can avoid it, but the costs are, to me, too high. E.g. my husband's grandmother loves to invite us over for dinner and dessert. She cooks things that are packed with fat or sugar. And she won't have us bring anything. If I don't eat, she will be unhappy. And as much as my diet is important to me, keeping a 85 years old great-grand mother of my babies happy is more important.
So, what I do - I plan ahead. If I am going to have a dessert there, I won't eat too much carbs before we go. I just make place for the calories in my daily plan. And I don't worry if I go over my plan a little. It's just one day, and we go there once or twice a month... I can easily make up for it the next day.
One of the wonderful things "dieting" (I hate the word, but you know what I mean, our new healthy life style) has taught me is to enjoy a little portion of wonderful meals. I chose very carefully what I want to eat. And then I have it. And a small portion of a top quality chocolate makes me much more happy than gobbling up two big chocolate bars as I used to do. So dont' worry to enjoy little sometihng here and there!