Solved

Date Binding Problem

Posted on 2006-06-30
1
256 Views
Last Modified: 2008-02-01
Hi,

Here's the question:  

I have a textbox and two numericUpDown's on my form.  The are all bound to one date field in my database, each with different formatting.  ie.  The textbox shows the date as "dd/MM/yyyy", numericUpDown1 as "HH" and NumericUpDown2 as "mm".

So I have the date displayed, the hour and the minutes displayed.  This works fine and the correct values do get displayed.  However, when I change the hour value or minute value in the numericUpDown controls and then click on another control the NumericUpDown's 'flick' back to there original values.

I think this is because I have to use the binding's parse event to parse the numericUpDown's value into the correct date format.  If i'm correct in this assumption how would I go about doing this?

I have already added code to the bindings Format events, just a bit unsure what I need to do on the Parse events.
0
Comment
Question by:AMLabels
1 Comment
 
LVL 20

Accepted Solution

by:
ElrondCT earned 250 total points
ID: 17021057
I'm not sure how to answer the exact question you're asking, but I can suggest an alternative way to get more or less the same results. You're binding three controls to the same database field, which raises potential problems of the different controls fighting with each other. I don't know how .NET is designed to handle such conflicts. It might be less confusing to use a single control for all of it.

If you use a DateTimePicker with the ShowUpDown property set to True, Format to Custom, and CustomFormat to "dd/MM/yyyy HH:mm", you'll get the numeric up/down built into the control for all the items within the control, and no need to do your own parsing.
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

Well, all of us have seen the multiple EXCEL.EXE's in task manager that won't die even if you call the .close, .dispose methods. Try this method to kill any excels in memory. You can copy the kill function to create a check function and replace the …
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…
In this video I am going to show you how to back up and restore Office 365 mailboxes using CodeTwo Backup for Office 365. Learn more about the tool used in this video here: http://www.codetwo.com/backup-for-office-365/ (http://www.codetwo.com/ba…

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

26 Experts available now in Live!

Get 1:1 Help Now