473,320 Members | 1,821 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

convertion error



Hello I am getting this error:
error CS0029: Cannot implicitly convert type 'System.EventHandler' to
'Janus.Windows.GridEX.ColumnActionEventHandler

Here are the declarations I made(all of them written in proper classes
and functions):

public delegate void ChangedEventHandler(object sender, EventArgs e);


public event ChangedEventHandler Changed;
protected virtual void OnChanged(EventArgs e)

{

if (Changed != null)

Changed(this, e);

}

OnChanged(EventArgs.Empty);

class EventListener

{
public EventListener(Janus.Windows.GridEX.GridEX grid,Reader re)

{

this.gridex.CellEdited+=new EventHandler(GridexChanged);

}

private void GridexChanged(object sender, EventArgs e)

{

MessageBox.Show(this.re2.EL.Get_Val(gridex.Row).St uck_Info.ToString());
}

}

Why do I get this error?
The weired thing is that if I am doing this for SelectionChanged eveny -
it doesn't happen.Why?
Thanks!


*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 16 '05 #1
3 1822
juli jul wrote:

Hello I am getting this error:
error CS0029: Cannot implicitly convert type 'System.EventHandler' to
'Janus.Windows.GridEX.ColumnActionEventHandler

Here are the declarations I made(all of them written in proper classes
and functions):

public delegate void ChangedEventHandler(object sender, EventArgs e);


public event ChangedEventHandler Changed;
protected virtual void OnChanged(EventArgs e)

{

if (Changed != null)

Changed(this, e);

}

OnChanged(EventArgs.Empty);

class EventListener

{
public EventListener(Janus.Windows.GridEX.GridEX grid,Reader re)

{

this.gridex.CellEdited+=new EventHandler(GridexChanged);

}

private void GridexChanged(object sender, EventArgs e)

{

MessageBox.Show(this.re2.EL.Get_Val(gridex.Row).St uck_Info.ToString());
}

}

Why do I get this error?
The weired thing is that if I am doing this for SelectionChanged eveny -
it doesn't happen.Why?
Thanks!


*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!


Hi,

the CellEdited event must be of type ColumnActionEventHandler. You have
to create a delegate of that type, and assign it to the event.

-> this.gridex.CellEdited += new ColumnActionEventHandler(GridexChanged);

the method 'GridexChanged' must have the same signature (same
parameters) as in the declaration of the delegate ColumnActionEventHandler.

You don't get this problem with the SelectionChanged event as it
probably is declared as System.EventHandler.

To conclude, events only accept delegates of the same type.

Cheers,
Benoit
Nov 16 '05 #2

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!
Nov 16 '05 #3
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
Nov 16 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Petr Studenovsky | last post by:
Hello I made small GUI test program in Visual Basic NET for SQL communication. I need some help with these problems. problem 1) If I change some settings in datagrid from properties window...
0
by: Konstantin Kivi | last post by:
I have problems getting character set convertion to work in 4.1.4 gamma under linux. Can sombody point me to the online recource other than standard MySQL doc so that I get more information.
6
by: Chiller | last post by:
I'm in the process of writing a class that performs functions on a Distance object. The object is created by entering details as "Distance a (5, km)" or "Distance b (3, cm)" etc. I wish to write...
2
by: Javier | last post by:
Hi All I'm in a nightmare trying to do a simple c++ program... I want to read a file that will have strings in a vector. The path where is the file is in a ini file. I did:
1
by: Vidar | last post by:
I have a problem in dotNET XSL convertion object. (XMLTRANSFORM) It won't convert UTF-8 to ISO-8859-1 I use this stylesheet for konvertion: <?xml version="1.0" encoding="ISO-8859-1"?> <!--...
4
by: juli | last post by:
Good afternoon! I have an error while trying to convert to DateTime ,here is the code and the error: ArrayList al = new ArrayList(); temp_str=Line.Split(' '); al.Add(temp_str); //...
4
by: kaikai | last post by:
Hi, I've got a problem while trying to make my source code clean. In a template: template<typename T> class A { public: T data; };
24
by: ChaosKCW | last post by:
Hi I am reading from an oracle database using cx_Oracle. I am writing to a SQLite database using apsw. The oracle database is returning utf-8 characters for euopean item names, ie special...
7
by: Filips Benoit | last post by:
Dear all, Tables: COMPANY: COM_ID, COM_NAME, ..... PROPERTY: PRP_ID, PRP_NAME, PRP_DATATYPE_ID, PRP_DEFAULT_VALUE ( nvarchar) COMPANY_PROPERTY: CPROP_COM_ID, CPROP_PRP_ID, CPROP_VALUE...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.