Thread: Takes 0 arguments?

  1. #1
    C(++)(#)
    Join Date
    Jul 2004
    Posts
    309

    Takes 0 arguments?

    Hello all, here I am begging for help again.
    Code:
    Code:
    //////////////////////////////////
    using System;
    using System.Windows.Forms;
    using System.Drawing;
    //////////////////////////////////
    
    //////////////////////////////////
    class App
    {
    	public static void Main()
    	{
    		Application.Run(new Start());
    	}
    }
    //////////////////////////////////
    
    //////////////////////////////////
    class Start:Form
    {
    	TextBox search;
    	Button newclass;
    	Button searchb;	
    	ComboBox clist;
    	Label searchlabel;
    	Label clistlabel;
    	//Button classdet;
    	
    	public Start()
    	{
    		search = new TextBox();
    		search.Location = new Point(8, 96);
    		search.Size = new Size(128, 30);
    		search.Anchor = AnchorStyles.Top|AnchorStyles.Bottom|AnchorStyles.Left|AnchorStyles.Right;
    		
    		newclass = new Button();
    		newclass.Location = new Point(298, 248);
    		newclass.Size = new Size(128, 56);
    		newclass.Text = "New class!";
    		newclass.Click += new System.EventHandler(addclass_OnClick());
    		
    		searchb = new Button();
    		searchb.Location = new Point(150, 96);
    		searchb.Size = new Size(56, 56);
    		searchb.Text = "Search";
    		searchb.Click += new System.EventHandler(searchclass_OnClick());
    		
    		clist = new ComboBox();
    		clist.Location = new Point(8,248);
    		clist.Size = new Size(280,21);
    		clist.DropDownWidth = 280;
    		clist.Items.AddRange( new object[] {"class list"});
    		clist.TabIndex = 7;
    		clist.Anchor = AnchorStyles.Top|AnchorStyles.Bottom|AnchorStyles.Left|AnchorStyles.Right;
    		
    		searchlabel = new Label();
    		searchlabel.Location = new Point(8,80);
    		searchlabel.Size = new Size(144, 23);
    		searchlabel.Text = "Search for class:";
    		
    		clistlabel = new Label();
    		clistlabel.Location = new Point(8, 228);
    		clistlabel.Size = new Size(144, 23);
    		clistlabel.Text = "Course list:";
    		
    		ClientSize = new Size(350, 325);
    		Controls.AddRange(new Control[]
    		{
    			search, newclass, searchb, clist, searchlabel, clistlabel
    		});
    		Text = "RR's Gradekeeper v 2.0.0";
    	}
    	
    	public void addclass_OnClick(object sender, EventArgs e)
    	{
    		try
    		{
    			clist.Items.Add(search.Text);
    		}
    		catch
    		{
    			MessageBox.Show("Add class failed");
    		}
    	}
    	
    	public void searchclass_OnClick(object sender, EventArgs e)
    	{
    		try
    		{
    			int index = clist.FindString(search.Text);
    			clist.SelectedIndex = index;
    		}
    		catch
    		{
    			MessageBox.Show("Search failed");
    		}
    	}
    }
    Error:
    Code:
    GK2\Gradekeeper2.cs(44,45): error CS1501: No overload for method
            'addclass_OnClick' takes '0' arguments
    GK2\Gradekeeper2.cs(78,14): (Location of symbol related to previous error)
    GK2\Gradekeeper2.cs(50,44): error CS1501: No overload for method
            'searchclass_OnClick' takes '0' arguments
    GK2\Gradekeeper2.cs(90,14): (Location of symbol related to previous error)
    Things I've tried:
    1) Making both functions with different names
    2) Making both functions private members
    3) Making both functions public members
    4) changing Object to object
    5) changing EventArgs to System.EventArgs
    6) Vice versa for #5

    I'm out of ideas on what it could be. If someone could point me in the right direction I'd be very very thankful.
    To code is divine

  2. #2
    C(++)(#)
    Join Date
    Jul 2004
    Posts
    309
    Doh I found it, I should have had the () when I called the eventhandler.
    To code is divine

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. command line arguments
    By vurentjie in forum C Programming
    Replies: 3
    Last Post: 06-22-2008, 06:46 AM
  2. Replies: 9
    Last Post: 01-02-2007, 04:22 PM
  3. Replies: 10
    Last Post: 09-27-2005, 12:49 PM
  4. NULL arguments in a shell program
    By gregulator in forum C Programming
    Replies: 4
    Last Post: 04-15-2004, 10:48 AM
  5. Replies: 2
    Last Post: 05-05-2002, 09:27 AM