Solved

VB.net 2005 - DateTimePicker (Close Dropdown)?

Posted on 2015-01-21
13
88 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
Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

 

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

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

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…
Parsing a CSV file is a task that we are confronted with regularly, and although there are a vast number of means to do this, as a newbie, the field can be confusing and the tools can seem complex. A simple solution to parsing a customized CSV fi…
Windows 10 is mostly good. However the one thing that annoys me is how many clicks you have to do to dial a VPN connection. You have to go to settings from the start menu, (2 clicks), Network and Internet (1 click), Click VPN (another click) then fi…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

785 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