Solved

Date Binding Problem

Posted on 2006-06-30
1
258 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

Simplifying Server Workload Migrations

This use case outlines the migration challenges that organizations face and how the Acronis AnyData Engine supports physical-to-physical (P2P), physical-to-virtual (P2V), virtual to physical (V2P), and cross-virtual (V2V) migration scenarios to address these challenges.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Get Top Visible Row of Datagridview 6 33
How to sort a list of objects using an item in an enclosed list 5 46
write xml in vb.net 2 24
Help with exporting to excel 4 28
Since .Net 2.0, Visual Basic has made it easy to create a splash screen and set it via the "Splash Screen" drop down in the Project Properties.  A splash screen set in this manner is automatically created, displayed and closed by the framework itsel…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

809 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