How to: Add Windows Forms to Outlook Solutions
Applies to |
---|
The information in this topic applies only to the specified Visual Studio Tools for Office projects and versions of Microsoft Office. Project type
Microsoft Office version
For more information, see Features Available by Application and Project Type. |
This example adds a Windows Form to a Microsoft Office Outlook project and displays the form to the user.
To add a Windows Form to an Outlook add-in solution
On the Project menu, click Add Windows Form.
In the Add New Item dialog, select Windows Form. Name the form MainForm and click Add.
Add a button to the form.
Double-click the button to add a Click event handler to the code and open the code view.
Add the following code to the Click event handler of the button.
Me.Close()
this.Close();
In Solution Explorer, double-click ThisAddIn.vb (in Visual Basic) or ThisAddIn.cs (in C#) to open the code file. Add the following code to the ThisApplication_StartUp event handler.
Dim mainForm As New MainForm() mainForm.ShowDialog()
MainForm formMain = new MainForm(); formMain.ShowDialog();
Press F5 to build and run the solution.