MonthCalendar Usage
-
Hey guys, I have a Form1 with a text box in it. When user clicks inside the text box it will pop up Form2 which has a MonthCalendar in it. Now after the user selects a date and click OK on Form2, i want that selected date string to be displayed in the Form1 text box. How can i get the Form2 date string to be displayed in Form1 text box? Thanks in advance.
-
Hey guys, I have a Form1 with a text box in it. When user clicks inside the text box it will pop up Form2 which has a MonthCalendar in it. Now after the user selects a date and click OK on Form2, i want that selected date string to be displayed in the Form1 text box. How can i get the Form2 date string to be displayed in Form1 text box? Thanks in advance.
The way I do it : On Form1 I listen for the Form2.FormClosed event like this
Form2 myForm2;
private void textBox1_TextChanged(object sender, EventArgs e)
{
myForm2 = new Form2();
myForm2.FormClosed += new FormClosedEventHandler(myForm2_FormClosed);
myForm2.Show();
}Then when the event happens :
void myForm2_FormClosed(object sender, FormClosedEventArgs e)
{
this.TextBox1.Text = myForm2.TheDate;
}On Form2 you need to have a Public property TheDate which you set when they click on your calendar OnOkClick you just close the form. hope that makes sense.
-
Hey guys, I have a Form1 with a text box in it. When user clicks inside the text box it will pop up Form2 which has a MonthCalendar in it. Now after the user selects a date and click OK on Form2, i want that selected date string to be displayed in the Form1 text box. How can i get the Form2 date string to be displayed in Form1 text box? Thanks in advance.