Solved

custom datetimepicker date on another tab page not shown correctly

Posted on 2008-10-30
3
599 Views
Last Modified: 2012-05-05
I have created a custom datetimepicker control - basically to make the presentation better when having no date set as well as a couple of other considerations.  This control works beautifully IF THE CONTROL IS IN VIEW/DISPLAYED/VISIBLE TO THE USER.
If I try to change its value (DTP1.Value = "8/3/2008") with the control not displayed (eg if DTP1 is on another tab page and not currently shown) then its OLD VALUE IS BEING DISPLAYED when I return to the control.  (On further testing, it turns out the .Value of the control IS the correct value ("8/3/2008 in this example) but the displayed value is not correct.)
Of course, I can write a crazy hack which temporarily shows the DTP control whilst I change its value, but that is soooo messy -- there must be a way to force my custom DTP control to show the new date value even though it is not currently in view.
Thanks in advance...
0
Comment
Question by:Sigh_Man
[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
  • 2
3 Comments
 
LVL 14

Assisted Solution

by:jake072
jake072 earned 50 total points
ID: 22926059
Have you tried doing a .Refresh after you set the value?

Jake
0
 
LVL 1

Author Comment

by:Sigh_Man
ID: 22981963
Hi there
Sorry for the delay.  I tried .Refresh.  I tried everything I could think of like Invalidating the control (to force redraw) but nothing seems to work.
After some reading on the net, I discovered that this is a bug in the framework 2.0.  Custom format datetimepickers do not change their displayed date if they are contained within a tab page if their value is set whilst their owning tab page is not visible.
Of course, I wrote a disgusting hack which momentarily "selects" the relevant tab page whilst the DTP's value is set and then reverts to the original tab page again afterwards.  The result however is a screen flifker whilst the tab page selection changes - compounded by the fact that I have several tab pages in the same control so I have to iterate through each.  Not pleasant, and I will be re-working this solution before clients get it!  :D
0
 
LVL 1

Accepted Solution

by:
Sigh_Man earned 0 total points
ID: 22983057
Sorry I cannot locate the webpages where I saw this issue mentioned.  Basically, the fix is:
DON'T USE CUSTOM FORMATS IN YOUR DATETIMEPICKERS IF those DateTimePickers are located on tab pages and those DTPs are to have their values changed whilst their 'owner' tab page is not visible at the time of the Value Change.
0

Featured Post

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.

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…
1.0 - Introduction Converting Visual Basic 6.0 (VB6) to Visual Basic 2008+ (VB.NET). If ever there was a subject full of murkiness and bad decisions, it is this one!   The first problem seems to be that people considering this task of converting…

726 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