Solved

VB.net 2005 - DateTimePicker (Close Dropdown)?

Posted on 2015-01-21
13
101 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 8
  • 4
13 Comments
 
LVL 101

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 86

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
Revamp Your Training Process

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action.

 

Author Comment

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

Thanks,
Mark
DateTimePicker.jpg
0
 
LVL 86

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
 
LVL 86

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 86

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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Since .Net 2.0, Visual Basic has made it easy to create a splash screen and set it via the "Splash Screen" drop down in the Project Properties.  A splash screen set in this manner is automatically created, displayed and closed by the framework itsel…
Microsoft Reports are based on a report definition, which is an XML file that describes data and layout for the report, with a different extension. You can create a client-side report definition language (*.rdlc) file with Visual Studio, and build g…
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…

622 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