11-02-2012 01:34 AM
Basically I'm making a custom tab on which I'm showing info on a contact taken from our ERP/Bookkeeping software.
What I'm trying to do however, is limit when the code on the custom tab gets executed. For example I don't want the plug-in to start querying the ERP database every time someone goes to another contact, this would be horribly inefficient and a complete waste of resources. I want this to only happen when the user is on the custom tab I added.
I first thought, seeing as I'm adding a custom control to a tabpage, which I'm adding to the Act Lay-out, I'd be able to call Me.Parent in the custom control to get what should be the TabPage, and from that TabPage call Parent again to get the TabControl.
But apparantly that doesn't seem to be working.
Basically I need some way of catching a TabIndex changed event from the TabControl, and checking if the current TabPage is my custom Tab.
Is there a way to do this in the Act SDK?
11-02-2012 07:41 AM
Why not check the me.visible property?
Please excuse this completley untested code since its from memory. I am in New Jersey ans still without power due to hurricane Sandy. My primary dev PC is dark but I have a laptop and a hot spot!
Public Class usrMyTab
' Create our internal handler
Dim RefreshMyTabEventHandler As New EventHandler(AddressOf RefreshMyTab)
' Attach to the ACT SDK event
Public sub new(ByVal HostApplication As Act.UI.ActApplication)
AddHandler HostApplication.CurrentContactChanged, RefreshMyTabEventHandler)
' Listening to ACT's events
Private Sub RefreshMyTab()
' Are we on the COntact Detial view?
If Me.HostApplication.CurrentViewName = ACTUIToolkit.ACTViews.ContactDetailViewName Then
' If YES then call the visibnle change event
' which will refresh the control
Private Sub usrMyTab_VisibleChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.VisibleChanged
' Only refresh if we are visible, When ACT raised the contact chnage event
' we may not be visible cuase the user has focus on another tab
If (Me.Visible = True) Then
' Your Refresh Code here!
Hope this helps
-- Jim Durkin
11-05-2012 02:07 AM
Never thought it'd be as simple as the visible property. Didn't expect the visible property to be set to false for a single tab when the user goes to another tab.