CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    Apr 1999
    Posts
    2

    Getting Events from Dynamicaly loaded controls

    How can I catch the events that are generated by Dynamicaly created controls.
    Something like:

    Dim a as VBControlExtender
    ...
    for i = 1 to 10
    a = new VB.Button
    me.Control.Add a
    next



    So, I want to be able to get the events that are generated by those buttons.

    Thanks.


  2. #2
    Join Date
    May 1999
    Location
    Omika, Japan
    Posts
    729

    Re: Getting Events from Dynamicaly loaded controls

    You should use
    Dim WithEvents a as TTT '( for exmpl)

    But this statement should be in Declarations section of the form, and the scope is always Form-level global.

    Once the above line is in place, automatically,
    a will appear in the drop-down combo on the LHS of the code window. And when you select it,
    any events that are associated with TTT (for ex) will the added to the combo on the RHS, and you can add event handlers, for these events by selecting them.

    By Default, i think, it always adds the event-stubs for a single control. For a control array, you might have to manually add the index parameter as first element of the default event-stub that vb generates.

    Ravi Kiran


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

Featured