Child Objects Raising Events in Parent Objects

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Enij
    New Member
    • Apr 2009
    • 13

    Child Objects Raising Events in Parent Objects

    Hi All,

    Long story short, I have created a ListView type control, using UserControls for the parent control and the ListViewItems. Most the of the control is written and works fine, right up to the point where I tried to replicate the 'Control.Select edItems(0).Inde x' property and the 'SelectedIndexC hanged' event.

    Each child object knows its index value, and could pass this value via the SelectedIndexCh anged event (assuming this is how it works in a normal ListView control -- user clicks on an item, and that item fires an event updating the selected index value in the parent object).

    How does the child object raise an event in the parent object? I have a feeling this could be done with Delegates, but I'm still learning about their usage.

    Thanks for any help
  • Enij
    New Member
    • Apr 2009
    • 13

    #2
    Figured it out.

    You just make the children object fire events and have the parent object handle those events, in turn firing an event for its parent to handle, continuing up the chain, etc.

    Came to me when I was pouring over delegates ...

    Comment

    Working...