Visio Guy

Visio Discussions => Programming & Code => Topic started by: ebachs10 on January 17, 2020, 10:14:46 AM

Title: Trigger event when property value is changed
Post by: ebachs10 on January 17, 2020, 10:14:46 AM
Hi All,

Is it possible to autmatic trigger an event when a property value changes?
To be more specific, I want to modify the drop-down list of my ElectricalTypeList, when the ConnectedTo property changes, see attached picture.

Thanks in advance.

/Esben
Title: Re: Trigger event when property value is changed
Post by: Croc on January 17, 2020, 11:58:37 AM
Here is one of the variants for creating a two-level list.
Title: Re: Trigger event when property value is changed
Post by: Croc on January 17, 2020, 12:52:07 PM
Sorry, but I was inattentive, so I brought a solution for ShapeSheet. :(
If we talk about events, then you can use the Visio Event Monitor add-on (from the Visio SDK). Event Monitor shows that when you select ShapeData from the list, only two events occur: FormulaChanged and CellChanged. They work. But these events have a drawback - they happen too often.
Another option is to use the QUEUEMARKEREVENT function and handle the app_MarkerEvent event. I like this option more.

More details:
Scratch.A1=QUEUEMARKEREVENT("MyCustomNotification")+DEPENDSON(Prop.Property1)

Dim WithEvents app As Visio.Application

Sub Start()
    Set app = ActiveDocument.Application
End Sub

Private Sub app_MarkerEvent(ByVal app As IVApplication, ByVal SequenceNum As Long, ByVal ContextString As String)
    MsgBox app.ActiveWindow.Selection(1).NameID & ": " & app.ActiveWindow.Selection(1).Cells("Prop.Property1").ResultStr(0)
End Sub
Title: Re: Trigger event when property value is changed
Post by: ebachs10 on January 20, 2020, 10:08:28 AM
Hi Croc

Just what I was looking for! I will try to implement and test your suggestion :)

/Esben
Title: Re: Trigger event when property value is changed
Post by: Croc on January 20, 2020, 12:24:28 PM
During this time, I managed to write an article on my blog. This is a Russian-language blog, but you can use GoogleTranslate.
https://visioport.ru/blog/index.php/primery/26-list2level
It will be better if you will take the formulas from the article. They are more accurate.