Results 1 to 5 of 5
  1. #1
    4 Star Lounger
    Join Date
    Feb 2001
    Location
    Gillingham, Kent, England
    Posts
    511
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Hard coding vs Dynamic (VB 6)

    When using dynamic controls, how easy is it to program their events?

    i.e. If I add a button to a form dynamically (at runtime), how do I then detect its on click event?

    I have the choice of hard coding a default set of buttons and editing (at runtime) their appearance to suit each customer, on attempting the dynamic method, which from a programming point of view is preferred.

    I was using a control, where every button added went on the same on click event and was picked out by the ID it was given, but the control didn't have the functionality that was required (MS Money style toolbar where the background changes depending on the page you're on), so that has been abandoned and replaced with a Coolbar.

    Am I destined to hard code every button on the page on does anyone have any advice about using the dynamic method?

    Any help would be much appreciated.

  2. #2
    Plutonium Lounger
    Join Date
    Dec 2000
    Location
    Sacramento, California, USA
    Posts
    16,775
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Hard coding vs Dynamic (VB 6)

    I take it that these buttons are not part of a control array. In that case, you have to create at least the shell for the event procedure in the code behind the button. If you're using buttons bound to a class, the rest of the handling can be in the class, so you wouldn't have to do any additional coding except to bind the new button to the class.
    Charlotte

  3. #3
    4 Star Lounger
    Join Date
    Feb 2001
    Location
    Gillingham, Kent, England
    Posts
    511
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Hard coding vs Dynamic (VB 6)

    Thanks for inadvertedly solving my problem Charlotte (potentially at least)!

    The buttons were not part of a control array, and I don't know enough about classes to follow your instructions. Seeing as you mentioned an array though, I will attempt to add some controls as array items and see if the array event handler picks up the runtime added control's events. Ill give it a go now and post back how it went.

  4. #4
    Plutonium Lounger
    Join Date
    Dec 2000
    Location
    Sacramento, California, USA
    Posts
    16,775
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Hard coding vs Dynamic (VB 6)

    Always glad to be of help ... even by accident. <img src=/S/grin.gif border=0 alt=grin width=15 height=15>
    Charlotte

  5. #5
    2 Star Lounger
    Join Date
    Sep 2007
    Location
    Chatham, Kent, England
    Posts
    214
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Hard coding vs Dynamic (VB 6)

    Serendipity?!

Posting Permissions

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