Nesting dynamically created buttons in dynamically created popups

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

Nesting dynamically created buttons in dynamically created popups
error creating buttons under popups when dynamic 
James Bambrough




Posts: 3
Joined: 2006-04-06
Hi,

I have a VB.net application that is dynamically building a collection of popups under a popup. Within this popup, there needs to be buttons. All of this needs to be created dynamically.

I am getting an unhandled exception, and I can't work out why. Any help would be gratefully recieved!

James

Code:


Private Sub getContacts()
        Dim cInfo As OSSDKWS.ContactInfo
        Dim dInfo As OSSDKWS.DeviceInfo
        Dim dcontext As OSSDKWS.DeviceContextInfo
        Dim newContact As New AddinExpress.MSO.ADXCommandBarPopup
        Dim newButton As New AddinExpress.MSO.ADXCommandBarButton
        Dim tmpStr As String
        Dim tmpCollection As New AddinExpress.MSO.ADXCommandBarPopupControlCollection(newContact)

        Me.cmdMyContacts.Controls.Clear()
        For Each cInfo In ossdkPWS.PAGetUserContactList(strCHandle, strPrimaryURI, OSSDKWS.ContactResponseType.UserContext, True)
            lbTemp.Items.Add(cInfo.userInfo.displayName)
            newContact = New AddinExpress.MSO.ADXCommandBarPopup
            newContact.Caption = "new user"
            tmpStr = cInfo.userInfo.displayName & " (" & cInfo.contextInfo.identityContextText & ")"
            'MsgBox(cInfo.contextInfo.identityContextText)
            newContact.Caption = tmpStr
            'now create availability information
            Me.cmdMyContacts.Controls.Add(newContact)
            For Each dInfo In cInfo.contextInfo.deviceInfoSet
                newButton = New AddinExpress.MSO.ADXCommandBarButton()
                newButton.Caption = dInfo.deviceType & " - " & dInfo.deviceContext.contextText
                Me.cmdMyContacts.Controls.Item(0).Collection.Add(newButton)
                newButton = Nothing
            Next
            newContact = Nothing
        Next
    End Sub
Posted 18 Dec, 2006 21:10:39 Top
Sergey Grischenko


Add-in Express team


Posts: 7233
Joined: 2004-07-05
Hi James.

The fact is that you use methods that are not designed working at runtime. Please download the following example to learn how you can add controls at runtime:
http://www.add-in-express.com/projects/dynamiccontrolsexample.zip

P.S. Note that we take up your forum requests in the order we receive them.
Besides, it may take us some time to investigate your issue. Please be sure we will let you know as soon as the best possible solution is found.
Posted 19 Dec, 2006 10:37:40 Top