Kirill Lapin
Guest
|
Hi there,
I can now get hold of the current instance of a pane from the AddinModule :) How can I grab ADXExcelTaskPane2 instance object from, say, the ADXExcelTaskPane1 class please? I tried to define a global variable in the Globals module:
Public ShowTaskPane1 As Boolean
Public ShowTaskPane2 As Boolean
Public ShowTaskPane3 As Boolean
Public CurrentTaskPane1Instance As ADXExcelTaskPane1
Public CurrentTaskPane2Instance As ADXExcelTaskPane2
Public CurrentTaskPane3Instance As ADXExcelTaskPane3
In the AddinModule:
Private Sub AddinModule_OnTaskPaneAfterCreate(sender As Object, instance As ADXTaskPane.ADXCustomTaskPaneInstance, control As Object) Handles Me.OnTaskPaneAfterCreate
CurrentTaskPane1Instance = AdxExcelTaskPanesCollectionItem1.TaskPaneInstance
CurrentTaskPane2Instance = AdxExcelTaskPanesCollectionItem2.TaskPaneInstance
CurrentTaskPane3Instance = AdxExcelTaskPanesCollectionItem3.TaskPaneInstance
End Sub
And then tried the following from the ADXExcelTaskPane1 module:
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
ShowTaskPane2 = True
CurrentTaskPane2Instance.Visible = ShowTaskPane2 End Sub
But no joy. What am I doing wrong please?.
I am getting the 'System.NullReferenceException' at the second line of the button click event, which probably means that CurrentTaskPane2Instance is Nothing.
Thanks,
KL |
|
Kirill Lapin
Guest
|
My current work around is to create a public function in the AddinModule that returns TaskPane object:
Public Function GetTaskPane1() As ADXExcelTaskPane1
Return TryCast(Me.AdxExcelTaskPanesCollectionItem1.TaskPaneInstance, ADXExcelTaskPane1)
End Function
Public Function GetTaskPane2() As ADXExcelTaskPane2
Return TryCast(Me.AdxExcelTaskPanesCollectionItem2.TaskPaneInstance, ADXExcelTaskPane2)
End Function
Public Function GetTaskPane3() As ADXExcelTaskPane3
Return TryCast(Me.AdxExcelTaskPanesCollectionItem3.TaskPaneInstance, ADXExcelTaskPane3)
End Function
and use it as follows from say ADXExcelTaskPane3 module:
Dim taskPane2 As ADXExcelTaskPane2 = AddinModule.GetTaskPane2
taskPane2.TreeView1.SelectedNode = Nothing
This works, but I am not sure if the object is already exposed by default. I can't find any property or method in the ADX generated code.
Thanks,
KL |
|
Dmitry Kostochko
Add-in Express team
Posts: 2875
Joined: 2004-04-05
|
Hi Kirill,
Your code looks correct. There exists another solution, you can use the CurrentInstance property of your add-in module, for example:
Dim item1 As ADXExcelTaskPanesCollectionItem =
MyAddin22.AddinModule.CurrentInstance.AdxExcelTaskPanesCollectionItem1
Dim item2 As ADXExcelTaskPanesCollectionItem =
MyAddin22.AddinModule.CurrentInstance.AdxExcelTaskPanesCollectionItem3
Dim item3 As ADXExcelTaskPanesCollectionItem =
MyAddin22.AddinModule.CurrentInstance.AdxExcelTaskPanesCollectionItem3
Note, you need to specify the namespace of your project (MyAddin22 in my case) to get access to the AddinModule shared properties. |
|