저는 C#을 처음 접했을 때 다음 코드 조각으로 고심하고 있습니다. 'knop'버튼을 클릭하면 'klik'메서드가 실행되어야합니다. 메서드는 양식에 'DrawMandel'에 의해 생성 된 비트 맵 'b'를 그려야합니다. 하지만 나는 지속적으로 ''위임자 'system.eventhandler'에게 과부하가 없음을 알립니다.일치하는 항목에 대한 오버로드가 없습니다. 'system.eventhandler'
using System;
using System.Windows.Forms;
using System.Drawing;
class Mandelbrot : Form
{
public Bitmap b;
public Mandelbrot()
{
Button knop;
knop = new Button();
knop.Location = new Point(370, 15);
knop.Size = new Size(50, 30);
knop.Text = "OK";
this.Text = "Mandelbrot 1.0";
this.ClientSize = new Size(800, 800);
knop.Click += this.klik;
this.Controls.Add(knop);
}
public void klik(PaintEventArgs pea, EventArgs e) {
Bitmap c = this.DrawMandel();
Graphics gr = pea.Graphics;
gr.DrawImage(b, 150, 200);
}
public Bitmap DrawMandel()
{
//function that creates the bitmap
return b;
}
static void Main() {
Application.Run(new Mandelbrot());
}
}
이벤트 처리기 대리자는 '개체를 보낸 사람을 가지고있는 EventArgs는 인수 목록을 e'. 너는 그렇지 않아. 그리고 기록을 위해서 나는'Click' 이벤트가'PaintEventArgs'를 가질 것이라고 의심합니다. – BoltClock
OnPaint() 메서드의 이름을 klik으로 바꾼 다음 단추 이벤트 핸들러에 연결하려고했습니다. + = klik 할당을 제거하고 폼 디자이너에서 버튼을 더블 클릭하면 새로운 버튼 핸들러가 생성됩니다. – StuartLC
이것은 시행 착오 프로그래밍입니다. 훨씬 더 많은 오류가있을 것입니다. 비트 맵을 그릴 수 있고 그것이 살아남기를 바랍니다. 지역 도서관을 방문하여 Winforms 프로그래밍 북을 확인하십시오. –