juli jul wrote:
Hello,
Thank you but I still got problems.I tried to change the type of handler
but I think that I still have problems with the type of an event.
Here is the code:
public delegate void ChangedEventHandler(object sender,
ColumnClickEventArgs e);
public event ChangedEventHandler Changed;
protected virtual void OnChanged(ColumnClickEventArgs e)
{
if (Changed != null)
Changed(this, e);
}
class EventListener
{
private Janus.Windows.GridEX.GridEX gridex;
private Reader re2;
public EventListener(Janus.Windows.GridEX.GridEX grid,Reader re)
{
this.gridex=grid;
this.gridex.CellEdited+=new ColumnActionEventHandler(GridexChanged);
}
private void GridexChanged(object sender, ColumnClickEventArgs e)
{
MessageBox.Show(this.re2.EL.Get_Val(gridex.Row).St uck_Info.ToString()
);
}
}
I also tried the ColumnClickEventHandler - but it also didn't help.
I am getting errors.
What am I doing wrong?
Thanks a lot!
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Hi,
ColumnActionEventHandler is defined as follow (if it hasn't been changed
by now):
public delegate void ColumnActionEventHandler(object sender,
ColumnActionEventArgs e);
which means, every event handler method, GridexChanged in your case,
must have the exact same parameters (called signature), in order to hook
it up on the event. You are specifying an *object* and
*ColumnClickEventArgs* in your method. The compiler won't accept this,
for a simple reason: when the event is fired, all handlers are invoked
with arguments of type *sender* and *ColumnActionEventArgs*, but your
method doesn't accept arguments of this type, as it has the wrong signature.
So, the delegate you assign (+=) to the event, must be of the same type
as the event (ColumnActionEventHandler), and the signature of the method
you pass to the constructor of the delegate must match the signature of
the delegate (object, ColumnActionEventArgs, and returning void).
1.
this.gridex.CellEdited += new ColumnActionEventHandler(GridexChanged);
(this one is correct)
2.
private void GridexChanged(object sender, ColumnActionEventArgs e)
{
MessageBox.Show(this.re2.EL.Get_Val(gridex.Row).St uck_Info.ToString()
}
Cheers,
Benoit