I am developing a calendar/appointment application and when i double click on the appointment while the application is running i want it to open the form with the information typed before and edit all.
private void editToolStripMenuItem_Click(object sender, EventArgs e)
{
}
I have a main form with a month calendar
private void monthCalendar_DateChanged(object sender, DateRangeEventArgs e)
{
labelDisplayedDate.Text=monthCalendar.SelectionRange.Start.ToLongDateString();
GetAppointmentsOnSelectedDate(monthCalendar.SelectionRange.Start);
panelDailyView.Invalidate();
}
a panel
private void panelDailyView_Paint(object sender, PaintEventArgs e)
{
int paintWidth = panelDailyView.ClientRectangle.Size.Width - vScrollBar.Width;
int paintHeight = panelDailyView.ClientRectangle.Size.Height;
int displayedRowCount = paintHeight / PanelRowHeight;
int panelTopRow;
int nextRow;
int apptStartRow;
int apptLength;
string dispTime;
Font font = new Font("Arial", 10);
Brush drawBrush = new SolidBrush(Color.DarkBlue);
Brush appointmentBrush = new SolidBrush(Color.LightBlue);
Graphics g = e.Graphics;
g.FillRectangle(new SolidBrush(Color.Linen), 0, 0, paintWidth, paintHeight);
panelTopRow = vScrollBar.Value;
if (_SelectedRow >= panelTopRow &&
_SelectedRow <= panelTopRow + displayedRowCount)
{
g.FillRectangle(new SolidBrush(Color.DarkKhaki),
0,
(_SelectedRow - panelTopRow) * PanelRowHeight,
paintWidth,
PanelRowHeight);
}
nextRow = panelTopRow;
for (int i = 0; i <= displayedRowCount; i++)
{
dispTime = (nextRow / 2).ToString("0#") + (nextRow % 2 == 0 ? ":00" : ":30");
nextRow++;
g.DrawString(dispTime, font, drawBrush, 2, (i * PanelRowHeight + 4));
g.DrawLine(Pens.DarkBlue, 0, i * PanelRowHeight, paintWidth, i * PanelRowHeight);
}
foreach (IAppointment appointment in _TodaysAppointments)
{
apptStartRow = Utility.ConvertTimeToRow(appointment.Start);
apptLength = Utility.ConvertLengthToRows(appointment.Length);
if (((apptStartRow >= panelTopRow) &&
(apptStartRow <= panelTopRow + displayedRowCount)) ||
(apptStartRow + apptLength > panelTopRow))
{
if (apptStartRow < panelTopRow)
{
apptLength = apptLength - (panelTopRow - apptStartRow);
apptStartRow = panelTopRow;
}
int apptDispStart = (apptStartRow - panelTopRow) * PanelRowHeight;
int apptDispLength = apptLength * PanelRowHeight;
if (apptDispStart + apptDispLength > paintHeight)
{
apptDispLength = paintHeight - apptDispStart;
}
Rectangle apptRectangle = new Rectangle(ApptOffset,
apptDispStart,
paintWidth - (ApptOffset * 2),
apptDispLength);
g.FillRectangle(appointmentBrush,
apptRectangle);
g.DrawRectangle(Pens.Black, apptRectangle);
if (Utility.ConvertTimeToRow(appointment.Start) >= panelTopRow)
{
Region oldClip = g.Clip;
g.Clip = new Region(apptRectangle);
g.DrawString(appointment.DisplayableDescription,
font,
drawBrush,
ApptOffset + 6,
apptDispStart + 4);
g.Clip = oldClip;
}
}
}
}
and 2 buttons
private void buttonNewAppt_Click(object sender, EventArgs e)
{
NewAppointment();
NewAppointment form2 = new NewAppointment();
form2.ShowDialog();
}
private void buttonNewReccuringAppt_Click(object sender, EventArgs e)
{
NewRecurringAppointment();
RecurringAppointmentForm form3 = new RecurringAppointmentForm();
form3.ShowDialog();
}
each button loads a form, the appointment form and the recurring appointment form. what i want is when an appointment is showing on the panel and double click it, to edit it. if it is an appointment the appointment form should load, or if it is recurring appointment, the recurring appointment form should load and edit it.