Solved

VB.net 2005 - DateTimePicker (Close Dropdown)?

Posted on 2015-01-21
13
85 Views
Last Modified: 2015-03-11
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
0
Comment
Question by:smithmrk
  • 8
  • 4
13 Comments
 
LVL 100

Expert Comment

by:mlmcc
ID: 40561994
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
 

Author Comment

by:smithmrk
ID: 40562007
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
 
LVL 85

Expert Comment

by:Mike Tomlinson
ID: 40562154
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
 

Author Comment

by:smithmrk
ID: 40562406
Nope!
See my attached screen shot!

Thanks,
Mark
DateTimePicker.jpg
0
 
LVL 85

Expert Comment

by:Mike Tomlinson
ID: 40562440
Did you remember to comment out or remove the ValueChanged() event handler?  It worked in my simple testing.
0
 

Author Comment

by:smithmrk
ID: 40562463
Yes, the only event I have now is the CloseUp.

Mark
0
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
LVL 85

Expert Comment

by:Mike Tomlinson
ID: 40562489
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
 

Author Comment

by:smithmrk
ID: 40562513
Nope didn't make a difference.

Mark
0
 

Author Comment

by:smithmrk
ID: 40562626
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
 
LVL 85

Accepted Solution

by:
Mike Tomlinson earned 500 total points
ID: 40562691
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
 

Author Comment

by:smithmrk
ID: 40562697
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
 

Author Comment

by:smithmrk
ID: 40562719
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
 

Author Closing Comment

by:smithmrk
ID: 40658935
Does Not Work in VS2005.

I appreciate the help!

Thanks,
mark
0

Featured Post

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

Suggested Solutions

This article explains how to create and use a custom WaterMark textbox class.  The custom WaterMark textbox class allows you to set the WaterMark Background Color and WaterMark text at design time.   IMAGE OF WATERMARKS STEPS Create VB …
Article by: jpaulino
XML Literals are a great way to handle XML files and the community doesn’t use it as much as it should.  An XML Literal is like a String (http://msdn.microsoft.com/en-us/library/system.string.aspx) Literal, only instead of starting and ending with w…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

706 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now