Using the new PropertyChanging event

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

Using the new PropertyChanging event
 
Eric Legault


Eric Legault


Posts: 67
Joined: 2009-01-27
I have an Outlook Add-In using Inspector Wrappers. I set a reference within each wrapper to a ADXRibbonEditBox control. I'm trying to proof having different ribbon control states/values with multiple Inspectors, so I'm simply setting the value of the edit box to the Subject of the current item:

Private Sub m_RibbonEditBoxTest_PropertyChanging(ByVal sender As Object, ByVal e As AddinExpress.MSO.ADXRibbonPropertyChangingEventArgs) Handles m_RibbonEditBoxTest.PropertyChanging
If e.PropertyType = AddinExpress.MSO.ADXRibbonControlPropertyType.Text Then
m_RibbonEditBoxTest.Invalidate()
m_RibbonEditBoxTest.Text = Me.Mail.Subject
End If
End Sub

This is obviously not correct, as I'm seeing the value of the last e-mail's subject line and never the current one.

What am I doing wrong?
Eric Legault [MVP - Outlook]
About: http://about.me/ericmlegault
Posted 16 Jun, 2009 01:55:38 Top
Andrei Smolin


Add-in Express team


Posts: 16197
Joined: 2006-05-11
Eric,

Try

If e.PropertyType = AddinExpress.MSO.ADXRibbonControlPropertyType.Text Then 
e.Value = Me.Mail.Subject 
End If 


Regards from Belarus (GMT+2),

Andrei Smolin
Add-in Express Team Leader
Posted 16 Jun, 2009 09:04:05 Top
Eric Legault


Eric Legault


Posts: 67
Joined: 2009-01-27
Okay, thanks Andrei - I get it now. I was also having problems by loading the Ribbon controls in each Inspector wrapper into module level variables. I quickly discovered this lead to multiple click events for the same ribbon control after more inspectors were loaded - it was additive!

I assume it's always best to work with the control events only in AddInModule in the case of multiple inspectors? I tend to put a lot of logic in Inspector wrappers or other classes referenced in a wrapper, and like to deal with Ribbon <-> message interactions there. If I have to call my individual messages in AddInModule, I have to do ugly things like find the active inspector in the wrapper collection in order to interface with the proper message's properties. It's not the worst, but I don't think it's very clean.

Thoughts?

Also - with the new Ribbon events in ADX 2009, when exactly would IRibbonControl.Invalidate() be used and why?
Eric Legault [MVP - Outlook]
About: http://about.me/ericmlegault
Posted 17 Jun, 2009 01:02:26 Top
Andrei Smolin


Add-in Express team


Posts: 16197
Joined: 2006-05-11
Hello Eric,

I have to do ugly things like find the active inspector in the wrapper collection in order to interface with the proper message's properties.


This is the only way I know.

when exactly would IRibbonControl.Invalidate() be used and why?


Invalidate is called in order to initiate the refresh of the control. Internally, it is used when you change properties of a Ribbon component in your code. If you don't use it, OnPropertyChanging is called when the Ribbon decides to refresh the control. If you call Invalidate, this will fire a number of OnPropertyChanging for a given Ribbon control.

Regards from Belarus (GMT+2),

Andrei Smolin
Add-in Express Team Leader
Posted 17 Jun, 2009 11:15:13 Top