Property Page questions

Add-in Express™ Support Service
That's what is more important than anything else

Property Page questions
 
Jimmy Kavanagh




Posts: 10
Joined: 2010-04-27
1) How can I tell when the "OK" or cancel button has been pressed. I have a property page with a textbox on it. I enter the characters "333" into the textbox. I click cancel. Then i show the property page again (via Tools:Options) the text box still has "333" in it.

2) The "Apply" button is not enabled when I make changes on a property page. When I enter text into a textbox on my property page the "Apply" button is not enabled.
Posted 31 May, 2010 06:16:35 Top
Jimmy Kavanagh




Posts: 10
Joined: 2010-04-27
Okay, i figured out question (2). I realised i needed to invoke OnStatusChange()

I still need to know if the "Cancel" button was pressed because at the moment the property page is retaining all the chares I enter into each textbox.

e.g.

Select Tools:Options:MyPropertyPage
enter 3333 into a textbox
Click "Cancel"
Select Tools:Options:MyPropertyPage

The textbox still has "3333" in it...
Posted 31 May, 2010 06:36:47 Top
Dmitry Kostochko


Add-in Express team


Posts: 2731
Joined: 2004-04-05
Hi Jimmy,

The point is that Outlook doesn't raise any event when the Cancel button is clicked. So, you need to initialize your option page controls with their values by using the Load event handler. And then store changed values in the Apply event handler.

Please see the sample code below:

using AddinExpress.MSO;

//...


private bool raiseEvent = true;

private void PropertyPage1_Load(object sender, EventArgs e)
{
	try
	{
		raiseEvent = false;
		this.textBox1.Text = (ADXAddinModule.CurrentInstance as AddinModule).TextBoxValue;
	}
	finally
	{
		raiseEvent = true;
	}
}

private void textBox1_TextChanged(object sender, EventArgs e)
{
	if (raiseEvent)
		this.OnStatusChange();
}

private void PropertyPage1_Apply(object sender, EventArgs e)
{
	(ADXAddinModule.CurrentInstance as AddinModule).TextBoxValue = this.textBox1.Text;
}
Posted 01 Jun, 2010 04:13:39 Top