Link to home
Start Free TrialLog in
Avatar of graber
graberFlag for United States of America

asked on

How do I get a FlowControlPanel to recieve messages from UserControls that it contains

I have a FlowLayoutPanel that is to hold a number of UserControls like the image shows each of the UserControls needs to alert the FlowLayoutPanel or the UserControl that holds it that changes in thier state.  I'm new to C Sharp and having a dikens of a time setting up the Delegate, EventArg, and event handler.  Thanks Guys and Gals
BitTwiddle.jpg
Avatar of Mike Tomlinson
Mike Tomlinson
Flag of United States of America image

Are they all the same TYPE of UserControl?...or just multiple instances of the same UserControl?
Avatar of graber

ASKER

The FlowControl is a UserControl with a LayoutFlowControl added from the toolbox the other UserControls, the one contained by the the LayoutFlowControl is an extenstion of UserControl. One of the message will pass will pass key states, another click with the instance that was clicked.  But I would also like to know how to pass messages between two unrealted classes as well.

public partial class SW : UserControl
{}
public partial class FlowPanel : UserControl
{}

Open in new window

BitTwiddle.jpg
ASKER CERTIFIED SOLUTION
Avatar of Mike Tomlinson
Mike Tomlinson
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of graber

ASKER

Thanks Idle... will give it a try tomarrow morning.  Just got "C# In Depth" by Jon Skeet in the mail.  I has several sections on this very thing.
No problem...take your time and ask questions.  You can pass anything out in your custom event.  Just need to change the "signature" of the delegate.
Avatar of graber

ASKER

Idle thanks for your patience.  I follow your example. Shouldn't the delegates be declared outside of the UserControl space?  I guess, since it's been declared public it doesn't matter.  In some of my research "they" are telling me to put my arguments into an EventArgs derived class of there own.  Is that necessary?

Thanks Idle
Gregg
I like to put the delegate with the UserControl since that is the "source" of the event.  Technically speaking it can be anywhere...really just a matter of preference here.  The example in EventArgs() has the delegate inside the source class as well:
http://msdn.microsoft.com/en-us/library/system.eventargs.aspx

Using EventArgs isn't necessary, though, it's just the model that Microsoft has decided to use in its own framework.  If you want to follow their lead then be my guest.  The "signature" of your delegate/event would at least look familiar to most people...  =)

Avatar of graber

ASKER

Thanks again Idle.