Solved

VB.net 2005 - DateTimePicker (Close Dropdown)?

Posted on 2015-01-21
13
97 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
Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

 

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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

Article by: Kraeven
Introduction Remote Share is a simple remote sharing tool, enabling you to see, add and remove remote or local shares. The application is written in VB.NET targeting the .NET framework 2.0. The source code and the compiled programs have been in…
It’s quite interesting for me as I worked with Excel using vb.net for some time. Here are some topics which I know want to share with others whom this might help. First of all if you are working with Excel then you need to Download the Following …
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…

728 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