delegate error

J

juli

Hello,

I have a listener class which deals with events .

There I have a function:
private void tChart1_Click(object
sender,System.Windows.Forms.MouseEventArgs e)
{
System.Console.WriteLine("aaa");
System.Console.WriteLine(this.line3.CalcXPos(1));


}
This function suppose to be activated by:
this.tChart1.ClickSeries+=new
Steema.TeeChart.TChart.SeriesEventHandler(tChart1_Click);

But I ger an error:
CS0123: Method 'WindowsApplication2.EventListener.tChart1_Click(object,
System.Windows.Forms.MouseEventArgs)' does not match delegate 'void
Steema.TeeChart.TChart.SeriesEventHandler(object,
Steema.TeeChart.Styles.Series, int, System.Windows.Forms.MouseEventArgs)'

The delagate I have is:
public delegate void ChangedEventHandler(object sender, EventArgs e);

Why do I get the error?
Thanks a lot!
 
J

James

Hi Juli,

This line:
this.tChart1.ClickSeries+=new
Steema.TeeChart.TChart.SeriesEventHandler(tChart1_Click);

says when the "ClickSeries" event gets raise by the tChart1 object
execute the tChart1_Click method. The problem is that the compiler is
telling you that the delegate for a
Steema.TeeChart.TChart.SeriesEventHandler is declared like this:

'void Steema.TeeChart.TChart.SeriesEventHandler(object,
Steema.TeeChart.Styles.Series, int,
System.Windows.Forms.MouseEventArgs)'

which is quite different to the signature of the method you are trying
to wire up to that event. You need to change your tChart1_Click method
to look like this:

private void tChart1_Click(object, Steema.TeeChart.Styles.Series, int,
System.Windows.Forms.MouseEventArgs)
Hope that helps,
James Fitzsimons
 
C

Christopher Ireland

juli said:
Hello,

I have a listener class which deals with events .


Why do I get the error?
Thanks a lot!

Another suggestion would be the following (using a .net winform application
with a TeeChart for .Net object on the form and a bar series added at
designtime):

this.bar1.Click += new
System.Windows.Forms.MouseEventHandler(this.bar1_Click);

private void Form1_Load(object sender, System.EventArgs e) {
bar1.FillSampleValues();

}

private void bar1_Click(object sender, System.Windows.Forms.MouseEventArgs
e) {
System.Diagnostics.Debug.WriteLine("aaa");
System.Diagnostics.Debug.WriteLine(e.X.ToString());
}

this needn't be coded manually as you can click on the bar series object
within the winform designer, choose events and double-click on the Click
event.

Best regards,

Christopher Ireland
Programmer
http://support.steema.com
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top