Click Event

L

Luis D Rojas

Hi,
i´ve added a new button to the menu bar in OL2003 and also i added a event
handler to that button like this:

_NewMenu = ( CommandBarPopup )_MainMenu.Controls["&New"];
_Button = ( CommandBarButton ) _NewMenu.Controls.Add(
MsoControlType.msoControlButton,_Missing, _Missing, _Missing, true );
_Button.Caption = "Apply Smart Plan";
_Button.Style = MsoButtonStyle.msoButtonIconAndCaption;
_Button.FaceId = 607;
_Button.BeginGroup = true;
_Button.Click +=new _CommandBarButtonEvents_ClickEventHandler(_Button_Click);

Then i open a new winform from this event like this
public void _Button_Click(Microsoft.Office.Core.CommandBarButton
barButton, ref bool Cancel)
{
View_EditSmartPlans splans = new View_EditSmartPlans();
splans.Show();
}

The problem that i have is that the event only works well once. I mean, the
first time OL is up, it executes calling the form, but if i close that form
and i try to click again to call the form, the event is fire.
Any suggestion about the reason of that?

best Regards
 
K

Ken Slovak - [MVP - Outlook]

Are you keeping a live reference to the button or letting it go out of
scope?
 
L

Luis D Rojas

Yes you were right, i had to declare the button as a class variable

Ken Slovak - said:
Are you keeping a live reference to the button or letting it go out of
scope?




Luis D Rojas said:
Hi,
i´ve added a new button to the menu bar in OL2003 and also i added a event
handler to that button like this:

_NewMenu = ( CommandBarPopup )_MainMenu.Controls["&New"];
_Button = ( CommandBarButton ) _NewMenu.Controls.Add(
MsoControlType.msoControlButton,_Missing, _Missing, _Missing, true );
_Button.Caption = "Apply Smart Plan";
_Button.Style = MsoButtonStyle.msoButtonIconAndCaption;
_Button.FaceId = 607;
_Button.BeginGroup = true;
_Button.Click +=new
_CommandBarButtonEvents_ClickEventHandler(_Button_Click);

Then i open a new winform from this event like this
public void _Button_Click(Microsoft.Office.Core.CommandBarButton
barButton, ref bool Cancel)
{
View_EditSmartPlans splans = new View_EditSmartPlans();
splans.Show();
}

The problem that i have is that the event only works well once. I mean,
the
first time OL is up, it executes calling the form, but if i close that
form
and i try to click again to call the form, the event is fire.
Any suggestion about the reason of that?

best Regards
 

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