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

Hybrid View

  1. #1
    Join Date
    Jul 2021
    Posts
    1

    User Control LIST - Setup & Handling of events - NOOB

    Hi guys,

    New here, so Hi Ya'll. It's been a LONG time since I've done any C# code, so this might sound elementary and dumb, but here goes. (BTW this is WinForms)

    I want to develop a control that contains various other standard controls like buttons and text boxes - I'll call it MYCONTROL. That's easy and I know how to do that, but how do I dynamically create instances of MYCONTROL so that I can:
    1. Respond to their events.
    2. Find out the specific instance and get access to it's data & methods.
    3. Communicate / update the instance's data and fire it's methods.
    4. Add & delete instances dynamically.

    I think that about covers it. I'd be happy to be pointed in the right direction or to look at some example code that I can learn from. Again - I'm rusty and my skills harken for over 10 years ago so please be kind! :-)

    Thanks

    Doug

  2. #2
    Arjay's Avatar
    Arjay is offline Moderator / EX MS MVP Power Poster
    Join Date
    Aug 2004
    Posts
    13,492

    Re: User Control LIST - Setup & Handling of events - NOOB

    The requirements are a bit vague but consider:
    1. Add events to your control. Users of your control would connect event handlers to the control.
    2. Not sure what this means. If you have created an instance, then presumably you have stored the instance in a variable. If you have multiple instances you can store the instances in a list or dictionary for access later.
    3. Use the approach in 2. above to gain access to its properties/methods.
    4. Again use the approach in 2. above to gain access to an instance to delete or to add a new instance to the list or dictionary.

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