M
moondaddy
C# 2.0
I have declared some event arguments like this:
public class ModeStateChangedEventArgs : EventArgs
{
Gen.DataState myState;
public ModeStateChangedEventArgs() { }
public ModeStateChangedEventArgs(Gen.DataState val)
{
myState = val;
}
public Gen.DataState MyState
{
get { return myState; }
}
}
In a business object I declare the event and use it like this:
Public class BizClass
{
public event EventHandler<ModeStateChangedEventArgs>
ModeStateChangedRaised;
protected virtual void
OnModeStateChangedRaised(ModeStateChangedEventArgs e)
{
try
{
EventHandler<ModeStateChangedEventArgs> handler =
ModeStateChangedRaised;
if (handler != null)
{
handler(this, e);
}
}
catch (Exception ex)
{
ExceptionHandler.ErrLog(ex);
}
}
//And I raise the event like this:
Void SomeMethod()
{
ModeStateChangedEventArgs arg = new
ModeStateChangedEventArgs(myModeState);
OnModeStateChangedRaised(arg);
}
}
Now is a list class I want to create instances of BizClass, assign and event
handler to them and then add them to the list.
Public class ListOfBizClass : BindingList< BizClass >, IBindingList
{
//This is where I need help...
public event EventHandler<ModeStateChangedEventArgs>
ModeStateChangedRaised;
protected virtual void
OnModeStateChangedRaised(ModeStateChangedEventArgs e)
{
try
{
EventHandler<ModeStateChangedEventArgs> handler =
ModeStateChangedRaised;
if (handler != null)
{
handler(this, e);
}
}
catch (Exception ex)
{
ExceptionHandler.ErrLog(ex);
}
}
public void GetListFromDatabase()
{
base.Clear();
dsContactMngr ds = oData.PersonGetRecShort();
foreach (dsContactMngr.tbPersonShortListRow dr in
ds.tbPersonShortList)
{
BizClass obj = new BizClass (dr.ID, dr.FName, dr.LName);
//This is where I get a compile error: 'new
EventHandler(OnModeStateChangedRaised)'
//Compile error says: 'No overload for 'OnModeStateChangedRaised' matches
delegate'
obj.ModeStateChangedRaised += new
EventHandler(OnModeStateChangedRaised);
base.Add(obj);
}
}
)
Can someone shed explain what I need to do here?
THANKS!
I have declared some event arguments like this:
public class ModeStateChangedEventArgs : EventArgs
{
Gen.DataState myState;
public ModeStateChangedEventArgs() { }
public ModeStateChangedEventArgs(Gen.DataState val)
{
myState = val;
}
public Gen.DataState MyState
{
get { return myState; }
}
}
In a business object I declare the event and use it like this:
Public class BizClass
{
public event EventHandler<ModeStateChangedEventArgs>
ModeStateChangedRaised;
protected virtual void
OnModeStateChangedRaised(ModeStateChangedEventArgs e)
{
try
{
EventHandler<ModeStateChangedEventArgs> handler =
ModeStateChangedRaised;
if (handler != null)
{
handler(this, e);
}
}
catch (Exception ex)
{
ExceptionHandler.ErrLog(ex);
}
}
//And I raise the event like this:
Void SomeMethod()
{
ModeStateChangedEventArgs arg = new
ModeStateChangedEventArgs(myModeState);
OnModeStateChangedRaised(arg);
}
}
Now is a list class I want to create instances of BizClass, assign and event
handler to them and then add them to the list.
Public class ListOfBizClass : BindingList< BizClass >, IBindingList
{
//This is where I need help...
public event EventHandler<ModeStateChangedEventArgs>
ModeStateChangedRaised;
protected virtual void
OnModeStateChangedRaised(ModeStateChangedEventArgs e)
{
try
{
EventHandler<ModeStateChangedEventArgs> handler =
ModeStateChangedRaised;
if (handler != null)
{
handler(this, e);
}
}
catch (Exception ex)
{
ExceptionHandler.ErrLog(ex);
}
}
public void GetListFromDatabase()
{
base.Clear();
dsContactMngr ds = oData.PersonGetRecShort();
foreach (dsContactMngr.tbPersonShortListRow dr in
ds.tbPersonShortList)
{
BizClass obj = new BizClass (dr.ID, dr.FName, dr.LName);
//This is where I get a compile error: 'new
EventHandler(OnModeStateChangedRaised)'
//Compile error says: 'No overload for 'OnModeStateChangedRaised' matches
delegate'
obj.ModeStateChangedRaised += new
EventHandler(OnModeStateChangedRaised);
base.Add(obj);
}
}
)
Can someone shed explain what I need to do here?
THANKS!