Hi, I'm having a problem with a program I am making, its a to do application, and on the main window there is a listview control, users are able to select an event and then edit it, trouble is, once I have changed the date and time deadline values, they do not go back to the main window, and there is no code I can find that will allow me to do this, here is the existing code for my edit button:
private void btnEdit_Click(object sender, EventArgs e)
{
try
{
if (null != listTask.SelectedItems[0])
{
EventForm EditEvent = new EventForm();
Event evt = TimerEvents[(Guid)listTask.SelectedItems[0].Tag];
EditEvent.taskName.Text = listTask.SelectedItems[0].Text;
EditEvent.timePicker.Value = evt.FireOn;
EditEvent.datePicker.Value = evt.FireOn;
EditEvent.notesBox.Text = listTask.SelectedItems[0].SubItems[3].Text;
if (DialogResult.OK == EditEvent.ShowDialog())
{
listTask.SelectedItems[0].Text = EditEvent.taskName.Text;
listTask.SelectedItems[0].SubItems[1] = EditEvent.timePicker.Value.ToString();
listTask.SelectedItems[0].SubItems[2] = EditEvent.datePicker.Value.ToString();
listTask.SelectedItems[0].SubItems[3].Text = EditEvent.notesBox.Text;
}
}
}
catch
{
MessageBox.Show("No task selected, please select a task to edit first", "Ben's Task Manager", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
}
}
The bit where the timepicker and datepicker bits are used does not work, inside the if part, EditEvent.timePicker.Value.ToString throws an error like, could not implicitely convert type string to listview subitem, same for the datepicker, could anyone suggest a way in which this would work?
Thanks
Ben