Hello Alexander,
You should be able to accomplish what you are trying to do with a custom ActiveX control. To get you started I have pasted the link to a tutorial below.
http://blogs.msdn.com/infopath/archive/2005/04/15/creating-an-infopath-custom-control-using-c-and-net.aspx
Matt Faus / Microsoft InfoPath MVPQdabra® Software / Streamline data gathering to turn process into knowledge