Be confident in who you are. Whether it is a formal function or an informal get together, the key is to be confident in yourself. Believing in yourself and knowing your worth in any situation is a key factor in letting people know that you are someone who knows what they are capable of. Having enough confidence is in itself a very attractive trait. You don't need to be smartest or the most physically appealing person to be confident about yourself. The belief that you're good enough makes you appear more attractive and approachable to the people around you. Confidence is reflected in both body language and mindset, so take care to heed both (see below).
Just be cautious not to be overconfident or abrupt, as that can turn people off. The best way is to just be yourself and be comfortable in your own way.