Solved

custom datetimepicker date on another tab page not shown correctly

Posted on 2008-10-30
3
595 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
  • 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Library to convert HTML to PDF. 8 57
LINQ - C# to VB convertion 12 48
how to use laptop or pad camera in vb.net windows application 2 55
Web Form VB.Net  import CSV 4 27
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…
Introduction When many people think of the WebBrowser (http://msdn.microsoft.com/en-us/library/2te2y1x6%28v=VS.85%29.aspx) control, they immediately think of a control which allows the viewing and navigation of web pages. While this is true, it's a…
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, f…
Many functions in Excel can make decisions. The most simple of these is the IF function: it returns a value depending on whether a condition you describe is true or false. Once you get the hang of using the IF function, you will find it easier to us…

863 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

21 Experts available now in Live!

Get 1:1 Help Now