public CustomFormRegion1(Outlook.FormRegion formRegion) : base(formRegion) { MSForms.UserForm form = formRegion.Form as MSForms.UserForm; _textBox1 = form.Controls["TextBox1"].To <Outlook.OlkTextBox>(); _commandButton1 = form.Controls["CommandButton1"].To <Outlook.OlkCommandButton>(); if (null != _commandButton1) { _commandButton1.ClickEvent += CommandButton1_ClickEvent; } }
public void BeforeFormRegionShow(Outlook.FormRegion FormRegion) { this.FormRegion = FormRegion; this.UserForm = FormRegion.Form as UserForm; System.Diagnostics.Debug.Write("BeforeFormRegionShow"); try { //System.Diagnostics.Debug.Write("BeforeFormRegionShow 1"); CommandButton1 = UserForm.Controls.Item("CommandButton1") as Outlook.OlkCommandButton; //System.Diagnostics.Debug.Write("BeforeFormRegionShow 2"); CommandButton1.ClickEvent += new Outlook.OlkCommandButton_ClickEventHandler(CommandButton1_Click); CommandButton2 = UserForm.Controls.Item("CommandButton2") as Outlook.OlkCommandButton; CommandButton2.ClickEvent += new Outlook.OlkCommandButton_ClickEventHandler(CommandButton2_Click); } catch (Exception ex) { MessageBox.Show(ex.ToString()); } }