こんにちは、特定のフォームの特定の場所にカレンダーを表示し、選択した日付を文字列で返す関数を作成しようとしています。
これは私がこれまでに持っているものです:
public static string ShowCalendar(Point locatieCalender, Form F1)
{
MonthCalendar calender = new MonthCalendar();
calender.Location = locatieCalender;
calender.Show();
calender.Visible = true;
calender.BringToFront();
calender.Parent = F1;
string date = calender.SelectionRange.Start.ToShortDateString();
DateTime dateValue = DateTime.Parse(date);
string dateForTextbox = dateValue.ToString("dd-MM-yyyy");
//calender.Hide();
return dateForTextbox;
}
関数呼び出しは次のようになります。
Point calenderLocatie = new Point(405, 69);
string dateForTextbox = HelpFunction.ShowCalendar(calenderLocatie, this);
txtPeriode_Tot.Text = dateForTextbox;
カレンダーはフォームに表示されますが、文字列は返されません。イベント ハンドラーを試しましたが、静的プロパティのため、これは機能しません。
助けてくれてありがとう。