Results 1 to 7 of 7

Thread: Dynamically added controls-A Quick Question

  1. #1

    Thread Starter
    Frenzied Member moinkhan's Avatar
    Join Date
    Jun 2000
    Location
    Karachi, Pakistan
    Posts
    2,011

    Dynamically added controls-A Quick Question

    Hi!

    Just lost my mind today...

    How do we attach an event handler to controls which are added dynamically through Controls Collection... ..

  2. #2
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: Dynamically added controls-A Quick Question

    You mean like using the ...
    VB Code:
    1. Public WithEvents SomeObject As ThatObject
    In the General Declarations section.
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  3. #3

    Thread Starter
    Frenzied Member moinkhan's Avatar
    Join Date
    Jun 2000
    Location
    Karachi, Pakistan
    Posts
    2,011

    Re: Dynamically added controls-A Quick Question

    Quote Originally Posted by RobDog888
    You mean like using the ...
    VB Code:
    1. Public WithEvents SomeObject As ThatObject
    In the General Declarations section.
    not exactly...
    i don't know how many controls are added at runtime...

  4. #4
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: Dynamically added controls-A Quick Question

    Well you could make them a control array. One procedure for each type of control. Then you can use the UBound and
    Index to determine how many?
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  5. #5
    Fanatic Member
    Join Date
    Mar 2002
    Location
    AUSTRALIA
    Posts
    603

    Re: Dynamically added controls-A Quick Question

    Hi,
    This thread may be of interest -
    Dynamic event handling
    Rob C

  6. #6

    Thread Starter
    Frenzied Member moinkhan's Avatar
    Join Date
    Jun 2000
    Location
    Karachi, Pakistan
    Posts
    2,011

    Re: Dynamically added controls-A Quick Question

    Quote Originally Posted by RobDog888
    Well you could make them a control array. One procedure for each type of control. Then you can use the UBound and
    Index to determine how many?
    No Control arrays.. i don't want to create one control for every type in design time...

  7. #7

    Thread Starter
    Frenzied Member moinkhan's Avatar
    Join Date
    Jun 2000
    Location
    Karachi, Pakistan
    Posts
    2,011

    Re: Dynamically added controls-A Quick Question

    Quote Originally Posted by RobCrombie
    Hi,
    This thread may be of interest -
    Dynamic event handling
    Thanx Rob...

    but this wudn't be suitable for me.. as i never know. which type of control is being added at run time... type is also decided on the fly. so i cannot declare with WithEvents... because WithEvents requires the type..

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