Results 1 to 4 of 4

Thread: processing events from dyn added controls

  1. #1

    Thread Starter
    New Member
    Join Date
    Jul 2000
    Posts
    10

    Question

    How can I process events from controls add dynmically?
    VBControlExtender can only handle non-intrinsic controls,
    so what is with the standard ones?

    thanks

  2. #2
    Frenzied Member Mark Sreeves's Avatar
    Join Date
    Nov 1999
    Location
    UK
    Posts
    1,845
    Are you loading controls as a control array?

    if so use the index of the control

    is this the sort of thing you mean?

    Code:
    Private Sub Command2_Click(Index As Integer)
        Select Case Index
        
        Case 0
            Debug.Print "Command2(0) was pressed"
        Case 1
             Debug.Print "Command2(1) was pressed"
        Case 2
             Debug.Print "Command2(2) was pressed"
        
        
        End Select
        
        
    End Sub
    Mark
    -------------------

  3. #3

    Thread Starter
    New Member
    Join Date
    Jul 2000
    Posts
    10

    Exclamation

    It is actually more complicated:

    I have forms in a project representing dialogs and I have a
    main form supposed to contain those dialogs.
    I copy the controls of these dialog forms into the main
    window by using frames as container for hiding and unhiding.

    Fact is, I have at designtime no idea of any controls in
    the main form, but I want to react on their events of
    course.

    ???

  4. #4
    Randalf the Red honeybee's Avatar
    Join Date
    Jun 2000
    Location
    off others' brains
    Posts
    4,345

    Well ....

    You can declare objects for each of the control type like:

    Dim WithEvents MyTextBox As TextBox




    Now, even though MyTextBox is an object used in the code, since we are using WithEvents, this object can contain all events of a text box, like you can have:

    Private Sub MyTextBox_Click()


    Private Sub MyTextBox_Change()


    and so on. You can define all events for a textbox into the events of MyTextBox. Then in the application, use the ActiveControl property of the form to retrieve the active control on it. Set the MyTextBox object to that control and your MyTextBox event will get executed for that control.

    Note one thing: In the above para, I am assuming that your control is a text box. If it is a different type of control you can declare another object of that type.

    Hope it helps.


    I am not a complete idiot. Some parts are still missing.
    Check out the rtf-help tutorial
    General VB Faq Thread
    Change is the only constant thing. I have not changed my signature in a long while and now it has started to stink!
    Get more power for your floppy disks. ; View honeybee's Elite Club:
    Use meaningfull thread titles. And add "[Resolved]" in the thread title when you have got a satisfactory response.
    And if that response was mine, please think about giving me a rep. I like to collect them!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width