Solved

Date Binding Problem

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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

This tutorial demonstrates one way to create an application that runs without any Forms but still has a GUI presence via an Icon in the System Tray. The magic lies in Inheriting from the ApplicationContext Class and passing that to Application.Ru…
Microsoft Reports are based on a report definition, which is an XML file that describes data and layout for the report, with a different extension. You can create a client-side report definition language (*.rdlc) file with Visual Studio, and build g…
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…
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial

751 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