/ Forums / Advansys Formativ / Creating Solutions with Formativ / Dynamic Form Component Events

  • Creator
  • #4464


    I was wondering how to call an event for a dynamically created component. I have created a new form called “MyTestForm” using the forms designer. This form contains a single panel called “pnlTest”.

    Then inside my solution code I have:

    Dim gTestDlg

    Sub Main(Client, GWEvent)

    ' Initialize a new dialog from my test form
    gTestDlg = MyTestForm

    ' Create a dynamic component at run time
    Set testEdit = TEdit.Create(gTestDlg.pnlTest)
    with testEdit
    .Parent = gTestDlg.pnlTest
    .left = 50
    .top = 10
    .height = 21
    .width = 160
    .name = "edtTest"
    .text = ""
    .visible = true
    .onClick = "testSub"
    end with

    ' Show the form

    End Sub

    Sub testSub(Sender)
    MsgBox("Called testSub")
    End Sub

    The edit box is created successfully, however the on click event does not get called. I have also tried a number of variations to the .onClick value attempting to pass in the sender variable, but I have not be able to get this event to be called.

    Any thoughts on what I am doing wrong would be greatly appreciated.

    Kind Regards,

    Jason Child

    [This message was edited by jasonchild on January 29, 2012 at 07:52 PM.]

  • Author
  • #8240

    Has anyone else needed to do this? I can’t be the only one heh. I’m not sure if my post above was clear.

    Basically I need to create a new component at run time on a pre-existing formativ form, and then assign an event handler to it.

    Any thoughts / feedback would be greatly appreciated.



    Support 1

    Unfortunately this does not seem to be possible. We have not found a way to get VBScript to assign an event handler dynamically.

    A couple of suggestions:

    • Try experimenting with the VBScript function GetRef (designed to support DHTML events), like this:
        .onClick = GetRef("testSub")

    • Develop a COM-enabled component to replace the Form, using a language that supports dynamically assigned event handlers (eg. Delphi, C#, VB.NET). You can create an instance of such a component from a Formativ applet, and pass data between the applet and component. You may find the featured topic .net modules useful.

    I hope this helps.

    Kind regards,
    Advansys Support


    Ok, thanks for your feedback. I tried using the GetRef function as suggested, but was unable to get this to call my event sub and I’m not sure I have the time in my project plan required to delvelop a com enabled solution to accomodate this need.

    This is unfortunate, but I guess I can achieve the same functionality using the limited Utilities.NewControlBoxDialog and either use a button to force an event or use chained dialogs for presenting required fields dependant on dynamic field values. A very outdated UI methodology but functional none the less.

    Thank you for your time looking into this, much appreciated.



    Support 1

    OK, thanks for the confirmation about GetRef.

    I suggest you seriously consider the option of a COM component, partly because of the obstacle you mention with NewControlBoxDialog in another thread. Also because it’s relatively easy to COM-enable such a component. The featured topic mentioned above includes a link to a working example.

    Good luck with the project.

    Kind regards,
    Advansys Support

    [This message was edited by Support 1 on February 01, 2012 at 03:33 PM.]

Viewing 4 replies - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.