VB.net 2005 - DateTimePicker (Close Dropdown)?

Hello Experts!

OK, so I have a DateTimePicker and when the user selects a NEW date is loads the data from that date into a DataGrid.  The problem is once the load of the data begins the Calendar still shows while the data is being loaded this could take a while...how can I close the DateTimePicker dropdown before the data begins to load?

It does finally disappear after all the data is loaded, but I would like the dropdown to go away before I load the data.

Thanks,
Mark
smithmrkAsked:
Who is Participating?

Improve company productivity with a Business Account.Sign Up

x
 
Mike TomlinsonConnect With a Mentor Middle School Assistant TeacherCommented:
That is strange.  It's not what I'm seeing on my end.  I'm using a different version of .Net, so it's possible there is a difference in the implementation.

Can you see if it behaves the same in a New, Blank project with just the DateTimePicker and the Sleep() call?
0
 
mlmccCommented:
Does the data load automatically on the selection or do you have code that executes to load the data?
If you have code, I believe there is a method to close the dropdown after you retrieve the data selected.

mlmcc
0
 
smithmrkAuthor Commented:
Here is the Code:

    Private Sub dtp_ReceiveDate_ValueChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles dtp_ReceiveDate.ValueChanged
        If cb_ClientList.SelectedIndex <> -1 Then
            Call ClientLoad(cb_ClientList.SelectedValue, sender, e)
        End If
    End Sub

How Can I close the DateTimePicker before it calls the ClientLoad Sub?
0
Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
Mike TomlinsonMiddle School Assistant TeacherCommented:
Instead of ValueChanged(), switch to the CloseUp() event:
    Private Sub dtp_ReceiveDate_CloseUp(sender As Object, e As EventArgs) Handles dtp_ReceiveDate.CloseUp
        If cb_ClientList.SelectedIndex <> -1 Then
            Call ClientLoad(cb_ClientList.SelectedValue, sender, e)
        End If
    End Sub

Open in new window


...then it will already be closed when you run ClientLoad().
0
 
smithmrkAuthor Commented:
Nope!
See my attached screen shot!

Thanks,
Mark
DateTimePicker.jpg
0
 
Mike TomlinsonMiddle School Assistant TeacherCommented:
Did you remember to comment out or remove the ValueChanged() event handler?  It worked in my simple testing.
0
 
smithmrkAuthor Commented:
Yes, the only event I have now is the CloseUp.

Mark
0
 
Mike TomlinsonMiddle School Assistant TeacherCommented:
I'm not sure what the difference is.  Here's a quick test:
    Private Sub dtp_ReceiveDate_CloseUp(sender As Object, e As EventArgs) Handles dtp_ReceiveDate.CloseUp
        System.Threading.Thread.Sleep(5000) ' purposely lock the form up: the calendar is already gone at this point on my system!
        ' ... do something else ...
    End Sub

Open in new window

On my system the calendar portion disappears and then the form locks up for five seconds.

You could try popping a DoEvents() in there, but I think something else is in play in your case:
    Private Sub dtp_ReceiveDate_CloseUp(sender As Object, e As EventArgs) Handles dtp_ReceiveDate.CloseUp
        Application.DoEvents()
        If cb_ClientList.SelectedIndex <> -1 Then
            Call ClientLoad(cb_ClientList.SelectedValue, sender, e)
        End If
    End Sub

Open in new window

0
 
smithmrkAuthor Commented:
Nope didn't make a difference.

Mark
0
 
smithmrkAuthor Commented:
OK, so do eliminate my ClientLoad function from being the issue I tried this and the DateTimePicker dropdown still doesn't disappear until after the 3 seconds.

    Private Sub dtp_ReceiveDate_CloseUp(ByVal sender As Object, ByVal e As System.EventArgs) Handles dtp_ReceiveDate.CloseUp
        Application.DoEvents()
        Me.Refresh()        
        If cb_ClientList.SelectedIndex <> -1 Then
            'Call ClientLoad(cb_ClientList.SelectedValue, sender, e)
            System.Threading.Thread.Sleep(3000)
        End If
    End Sub

Strange???

Mark
0
 
smithmrkAuthor Commented:
Yeah I'll try that.
I'm using VS2005...it may have been fixed in later versions.

I'll let you know what I find out.

Mark
0
 
smithmrkAuthor Commented:
Did the same thing in a NEW Project with just the DateTimePicker and I set the sleep for 5 seconds just to make sure it was acting the same way.

Must be a bug in VS2005...Not a big deal I was just wondering if there was a way to fix it and if I was missing something.

Thanks,
Mark
0
 
smithmrkAuthor Commented:
Does Not Work in VS2005.

I appreciate the help!

Thanks,
mark
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.