This post is based on my previous article in which i describe how to deploy an InfoPath form via Visual Studio Solution. Please read it first and then come back to this post cause we will use the example and add the code behind.
Ok, if you like to add code behind in your InfoPath form you normally have installed the VSTA Addin in your Office package. Afterwards you can choose which language for programming you would like to have.
After that you can add a loading event to your form.
It opens the Visual Studio Project.
Now you can deploy this project and you will find a .dll in your bin folder. Remember this. But first you publish your form again and put it into your solution again like in my previous post.
In your solution you add the .dll of the form code by using the add existing item menu to your module. Afterwords you have to do some settings. In the Solution Explorer mark your .dll file and delete the path at Deployment Location.
In the element file of your module the .dll should not be mentioned anymore like in this screen:
Please check your feature.xml file. It should contain the .dll but without the path to your module.
Now you can deploy your InfoPath form into Central Administration with having code behind.
..:: I LIKE SHAREPOINT ::..