Results 1 to 4 of 4

Thread: [RESOLVED] Adding Events To Custom Controls

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Aug 2011
    Posts
    272

    Resolved [RESOLVED] Adding Events To Custom Controls

    I have a custom control that has a series of comboboxes. In my application, I programmatically add the control to several programmatically created tabs. When the first combobox value is changed, I would like to iterate through each of the controls and set their value to match. I know how to iterate through the tabs and find a particular combobox within each control, but I haven't been able to figure out how to assign an event to those comboboxes to trigger the search in the first place.

    How does one assign an even to a subcontrol within a custom control?

  2. #2
    Angel of Code Niya's Avatar
    Join Date
    Nov 2011
    Posts
    9,017

    Re: Adding Events To Custom Controls

    Its very easy. Use AddHandler.
    Treeview with NodeAdded/NodesRemoved events | BlinkLabel control | Calculate Permutations | Object Enums | ComboBox with centered items | .Net Internals article(not mine) | Wizard Control | Understanding Multi-Threading | Simple file compression | Demon Arena

    Copy/move files using Windows Shell | I'm not wanted

    C++ programmers will dismiss you as a cretinous simpleton for your inability to keep track of pointers chained 6 levels deep and Java programmers will pillory you for buying into the evils of Microsoft. Meanwhile C# programmers will get paid just a little bit more than you for writing exactly the same code and VB6 programmers will continue to whitter on about "footprints". - FunkyDexter

    There's just no reason to use garbage like InputBox. - jmcilhinney

    The threads I start are Niya and Olaf free zones. No arguing about the benefits of VB6 over .NET here please. Happiness must reign. - yereverluvinuncleber

  3. #3

    Thread Starter
    Hyperactive Member
    Join Date
    Aug 2011
    Posts
    272

    Re: Adding Events To Custom Controls

    I've used AddHandler on a programmatically created standard control, but how would I do that with MyCustomControl.ComboBox1? Loop through the control at creation, find the Combobox and add it that way?

  4. #4
    Angel of Code Niya's Avatar
    Join Date
    Nov 2011
    Posts
    9,017

    Re: Adding Events To Custom Controls

    The custom control would have a public Controls property which would give you a collection of all the controls on its surface. Use that in combination with AddHandler.
    Treeview with NodeAdded/NodesRemoved events | BlinkLabel control | Calculate Permutations | Object Enums | ComboBox with centered items | .Net Internals article(not mine) | Wizard Control | Understanding Multi-Threading | Simple file compression | Demon Arena

    Copy/move files using Windows Shell | I'm not wanted

    C++ programmers will dismiss you as a cretinous simpleton for your inability to keep track of pointers chained 6 levels deep and Java programmers will pillory you for buying into the evils of Microsoft. Meanwhile C# programmers will get paid just a little bit more than you for writing exactly the same code and VB6 programmers will continue to whitter on about "footprints". - FunkyDexter

    There's just no reason to use garbage like InputBox. - jmcilhinney

    The threads I start are Niya and Olaf free zones. No arguing about the benefits of VB6 over .NET here please. Happiness must reign. - yereverluvinuncleber

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