0
private async void submitRequestButton_Click(DateTime dateFormat, DateTime startFormat, DateTime endFormat, EventArgs e)
{
    ParseObject request = new ParseObject("Shifts");
    request["Name"] = ParseUser.CurrentUser.Username;
    request["Shift"] = shiftBox.Text;
    request["Rental"] = rentalBox.Checked;
    request["Location"] = locationBox.Text;
    request["Date"] = dateFormat.ToString("MMMM dd, yyyy");
    request["startTime"] = startFormat.ToString("t", CultureInfo.CreateSpecificCulture("en-us"));
    request["endTime"] = endFormat.ToString("t", CultureInfo.CreateSpecificCulture("en-us"));

    await request.SaveAsync();
}

private DateTime datePicker_ValueChanged(DateTime dateFormat, EventArgs e)
{
    dateFormat = datePicker.Value;

    return dateFormat;
}

private DateTime startTimePicker_ValueChanged(DateTime startFormat, EventArgs e)
{
    startFormat = startTimePicker.Value;

    return startFormat;
}

private DateTime endTimePicker_ValueChanged(DateTime endFormat, EventArgs e)
{
    endFormat = endTimePicker.Value;

    return endFormat;
}

I don't understand why I am getting this error for methods 2, 3 and 4.

No overload for "method" matches delegate 'System.EventHandler'?

If you need to see more code just let me know. I'm pretty sure everything is hooked up properly.

It looks like the error is coming from: this.datePicker.ValueChanged += new System.EventHandler(this.datePicker_ValueChanged); (the same goes for the other 2 methods).

Please help! I'm new to C# so I don't exactly understand why this error is occurring.

Sanjeev Singh
  • 3,976
  • 3
  • 33
  • 38
nick9999
  • 601
  • 1
  • 8
  • 22

2 Answers2

2

The signatures on all of your event methods are wrong. The first parameter should be an object representing the control that fired the event, and the return type should be void.

private void datePicker_ValueChanged(object sender, EventArgs e)
{
    // Either cast "sender" to the appropriate type of control,
    //  or just reference the control directly if only one could be subscribed

    datePicker.Value
}

It looks like you don't even need these events though. Just reference the controls from within the other method when you execute it.

request["Date"] = datePicker.Value.ToString("MMMM dd, yyyy");
request["startTime"] = startTimePicker.Value.ToString("t", CultureInfo.CreateSpecificCulture("en-us"));
request["endTime"] = endTimePicker.Value.ToString("t", CultureInfo.CreateSpecificCulture("en-us"));
Grant Winney
  • 65,241
  • 13
  • 115
  • 165
1

Your event methods should look like this:

private void datePicker_ValueChanged(object sender, EventArgs e)
{
    DateTimePicker picker = (DateTimePicker)sender;
    //do stuff
}
Jon Tirjan
  • 3,556
  • 2
  • 16
  • 24