Windows C# 中的表单错误

Windows Forms in c# error

对于我的一个项目,我需要编写一个程序来显示产品列表,并在其左侧打勾和/或打叉。除了表单部分,我已经对所有内容进行了排序 我遇到过这个问题:

class Presentation
{
    static Form Window = new Form();
    static public void Configuration()
    {
        Window.Height = 800;
        Window.Width = 800;
        Window.Text = "Homework";

        Graphics draw = Window.CreateGraphics();

        Window.Paint += Window_Paint();

        Window.Show();
    }
    void Window_Paint(System.Object sender, PaintEventArgs e)
    {
        AnyOtherConfigurations(e);
    }
    static public void AnyOtherConfigurations(PaintEventArgs e)
    {
        Pen pen1 = new Pen(Color.Red);
        Font font = new Font(FontFamily.GenericSansSerif, 8, 
        FontStyle.Regular, GraphicsUnit.Millimeter);
        Graphics draw = Window.CreateGraphics();
        e.Graphics.FillEllipse(new SolidBrush(Color.Yellow),x,y,80,80);
        draw.DrawRectangle(pen1, 0, 0, 90, 90);

    }
}

它给我的错误是:

CS7036 There is no argument given that corresponds to the required formal parameter 'sender' of 'UserQuery.Presentation.Window_Paint(object, PaintEventArgs)'
CS0029 Cannot implicitly convert type 'void' to 'System.Windows.Forms.PaintEventHandler'

任何人都可以提出发生这种情况的原因并就如何解决它提供建议吗?

不写

Object.Event += Method();

但是

Object.Event += Method;

相反。

事件侦听器需要对使用委托的方法的引用,而不是对方法本身的返回值的引用。这解释了你的错误。