OutLook and Windows Forms

M

Mallikarjun

I have created a commandBarbutton on a Commandbarpoup on a
Mailitem inspector. When I Click the button it should
open a Windows form Which has a textbox and Datagrid.
The form is opened for the first 5 times of button Click.
Later it does not.
Infact for the 6th time the Click event does not fire at
all.
Here is the code I have used.
-----------------------------------------------------------
-------------------------------------
Connect.cs
-----------------------------------------------------------
-------------------------------------


private void CreatePopUp(CommandBar oStandardBar)
{

CmdBarPopup =(CommandBarPopup) oStandardBar.FindControl
(System.Reflection. Missing.Value,
System.Reflection.Missing.Value,"MailingPopup",System.
Reflection.Missing.Value,System.Reflection.Missing.Value);

if(CmdBarPopup == null)
{
// Add a pop-up menu to the command bar
object oMissing=System.Reflection.Missing.Value;
CmdBarPopup = (CommandBarPopup)
oStandardBar.Controls.Add(
MsoControlType.msoControlPopup,
System.Reflection.Missing.Value,
System.Reflection.Missing.Value,
System.Reflection.Missing.Value,
true);
// Add a separator before the pop-up button.
CmdBarPopup.BeginGroup = true;
// Set the caption
CmdBarPopup.Caption = "Select Groups !!";
CmdBarPopup.Tag="MailingPopup";
// Add a pop-up.
CommandBarPopup oPopup = (CommandBarPopup)
CmdBarPopup.CommandBar.Controls.Add
(MsoControlType.msoControlPopup,
oMissing,
oMissing,
oMissing,
true);
oPopup.Caption="PIM-IT";
oPopup.Visible=true;
// Add a button to the pop-up
CommandBarButton oPopupButton = (CommandBarButton)
oPopup.CommandBar.Controls.Add
(MsoControlType.msoControlButton,oMissing,oMissing,oMissing
,true);
// Change the face ID and caption for the button.
oPopupButton.Style=MsoButtonStyle.msoButtonCaption;
oPopupButton.FaceId = 643;
oPopupButton.Caption = "Phone Details";
oPopupButton.Visible=true;
// Set up a delegate for the Click event.

Microsoft.Office.Core._CommandBarButtonEvents_ClickEventHan
dler oPopupButtonHandler = new
Microsoft.Office.Core._CommandBarButtonEvents_ClickEventHan
dler(oPopupButton_Click);
oPopupButton.Click += oPopupButtonHandler;

CmdBarPopup.OnAction = "<Mailinglist.Connect>";
// Show the command bar to the user.
CmdBarPopup.Visible = true;
}

}
/// <summary>
///
/// </summary>
/// <param name="Ctrl"></param>
/// <param name="Cancel"></param>
private void oPopupButton_Click(CommandBarButton Ctrl,
ref bool Cancel)
{
ShowPhoneList frm1= new ShowPhoneList();
frm1.Show();

}
#endregion

/// <summary>
/// Implements the OnBeginShutdown method of the
IDTExtensibility2 interface.
/// Receives notification that the host application
is being unloaded.
/// </summary>
/// <param term='custom'>
/// Array of parameters that are host application
specific.
/// </param>
/// <seealso class='IDTExtensibility2' />
public void OnBeginShutdown(ref System.Array custom)
{
CommandBars oCommandBars
=applicationObject.ActiveInspector().CommandBars;
CommandBar MailingPopupBar = oCommandBars
["MailingPopup"];
MailingPopupBar.Delete();

}

-----------------------------------------------------------
-------------------------------------
-----------------------------------------------------------
-------------------------------------

-----------------------------------------------------------
-------------------------------------
ShowPhoneList.cs
-----------------------------------------------------------
-------------------------------------

using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;

namespace MobileList
{
/// <summary>
/// Summary description for ShowPhoneList.
/// </summary>
public class ShowPhoneList : System.Windows.Forms.Form
{
private System.Windows.Forms.TextBox txtSearch;
private System.Windows.Forms.DataGrid dataGrid1;
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.Container components =
null;

public ShowPhoneList()
{
//
// Required for Windows Form Designer support
//
InitializeComponent();

//
// TODO: Add any constructor code after
InitializeComponent call
//
}

/// <summary>
/// Clean up any resources being used.
/// </summary>
protected override void Dispose( bool disposing )
{
if( disposing )
{
if(components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}

#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.txtSearch = new System.Windows.Forms.TextBox();
this.dataGrid1 = new System.Windows.Forms.DataGrid();
((System.ComponentModel.ISupportInitialize)
(this.dataGrid1)).BeginInit();
this.SuspendLayout();
//
// txtSearch
//
this.txtSearch.Location = new System.Drawing.Point(16,
16);
this.txtSearch.Name = "txtSearch";
this.txtSearch.Size = new System.Drawing.Size(160, 20);
this.txtSearch.TabIndex = 0;
this.txtSearch.Text = "";
//
// dataGrid1
//
this.dataGrid1.CaptionBackColor =
System.Drawing.SystemColors.Info;
this.dataGrid1.CaptionFont = new System.Drawing.Font
("Arial", 9F, System.Drawing.FontStyle.Bold,
System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
this.dataGrid1.CaptionForeColor =
System.Drawing.SystemColors.Desktop;
this.dataGrid1.CaptionText = "Phone List";
this.dataGrid1.DataMember = "";
this.dataGrid1.HeaderForeColor =
System.Drawing.SystemColors.ControlText;
this.dataGrid1.Location = new System.Drawing.Point(16,
48);
this.dataGrid1.Name = "dataGrid1";
this.dataGrid1.Size = new System.Drawing.Size(440, 184);
this.dataGrid1.TabIndex = 1;
//
// ShowPhoneList
//
this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
this.ClientSize = new System.Drawing.Size(504, 269);
this.Controls.Add(this.dataGrid1);
this.Controls.Add(this.txtSearch);
this.Name = "ShowPhoneList";
this.Text = "ShowPhoneList";
((System.ComponentModel.ISupportInitialize)
(this.dataGrid1)).EndInit();
this.ResumeLayout(false);

}
#endregion
}
}
-----------------------------------------------------------
-------------------------------------

Can any help me in fixing this such that the form appear
everytime I click the Button
Thanks and Regds
Mallikarjun S B
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top