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......

can u make it more clear ...? its seems a little vague..

how are you getting the date in Main form textbox

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.

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

tried.....but it does not worked....I wonder why...!!

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.

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...

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.