void region_Close() { // Unhook the Click event sink, clean up all OM references, and notify our parent we're closing. commandButton1.Click -= new Outlook.OlkCommandButtonEvents_ClickEventHandler(commandButton1_Click); commandButton1 = null; textBox1 = null; if (Close != null) { Close(this, EventArgs.Empty); } }
public FormRegionControls(Outlook.FormRegion region) { // Fetch the controls from the form, to initialize our managed references. UserForm form = region.Form as UserForm; Controls formControls = form.Controls; textBox1 = formControls.Item("TextBox1") as Outlook.OlkTextBox; commandButton1 = formControls.Item("CommandButton1") as Outlook.OlkCommandButton; commandButton1.Click += new Outlook.OlkCommandButtonEvents_ClickEventHandler(commandButton1_Click); region.Close += new Outlook.FormRegionEvents_CloseEventHandler(region_Close); }