Dear All,

How can I do this

I created 2 forms...

1 is the main form and another is monthcalendar form.

When i cliked on a button in MAIN form it will lik to another form which is MONTHCALENDAR form.

When I click on the date in MonthCalendar ,

How can I display the selected adte in textbox which is in the MAIN form?

Kindly assist..Its urgent......

In my Main form, I put a button which will link to another form which is monthcalendar function when i cliked on the button.

So, what I want is.

I click on the date in monthcalendar , the monthcalendar form will close and the date value will be displayed in the textbox in Main form.

I wish my clarification clear for your understanding?

See if this helps.

Public Class Form2

    Private Sub Form2_FormClosing(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing
        Form1.TextBox1.Text = MonthCalendar1.SelectionStart.ToShortDateString  '// .SelectionStart gets the first selected Date.
    End Sub
End Class

answer deleted.

sorry, late response, kept he window too long before responding.

Edited 5 Years Ago by debasisdas: n/a

codeorder,

it does not works...........

Nothing happen when I clicked on the date in the MonthCalendar

debasisdas,

yea...your are absolutely right....that's what I wanted to have ...

Can you help me?

In my Main form, I put a button which will link to another form which is monthcalendar function when i cliked on the button.

So, what I want is.

I click on the date in monthcalendar , the monthcalendar form will close and the date value will be displayed in the textbox in Main form.

I wish my clarification clear for your understanding?

ok i understand.. try the way CODEORDER showed you

My apologies, I did not notice the "form will close" from your previous reply. Use the DateSelected event instead of the FormClosing.

Private Sub MonthCalendar1_DateSelected(ByVal sender As Object, ByVal e As System.Windows.Forms.DateRangeEventArgs) Handles MonthCalendar1.DateSelected
        Form1.TextBox1.Text = MonthCalendar1.SelectionStart.ToShortDateString  '// .SelectionStart gets the first selected Date.
        Me.Close() '// close Form after selecting Date.
    End Sub

Coderorder,

The codes works 50%. Yes, the MonthCalendar form is close, but the selected date is not display in textbox?

Is there any missing codes?

My apologies, I did not notice the "form will close" from your previous reply. Use the DateSelected event instead of the FormClosing.

Private Sub MonthCalendar1_DateSelected(ByVal sender As Object, ByVal e As System.Windows.Forms.DateRangeEventArgs) Handles MonthCalendar1.DateSelected
        Form1.TextBox1.Text = MonthCalendar1.SelectionStart.ToShortDateString  '// .SelectionStart gets the first selected Date.
        Me.Close() '// close Form after selecting Date.
    End Sub

Codeorder's Solution works fine

Hi Codeorder,

It gave me the same output.. When I clicked on the date, yes the form closed but the selected date is not display in textbox...

hmmmmm......

Did you change Form1 to your Form's.Name and the same for the TextBox?
.If you still have issues, try it in a new project.
..Could be something in your code that is blocking the value being sent from your MonthCalendar to your Main Form's TextBox.

Edited 5 Years Ago by codeorder: n/a

yes, I have changed everything based on my own declaration...

What should be the possiblity of blocking the value to pass to main form?

Kindly assist me on this...

This article has been dead for over six months. Start a new discussion instead.