Solved

Date Binding Problem

Posted on 2006-06-30
1
254 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
Comment Utility
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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Convert string to date 3 39
Tabcontrol Caption? 1 21
Get String split 5 31
Unable  to create new object 9 19
I think the Typed DataTable and Typed DataSet are very good options when working with data, but I don't like auto-generated code. First, I create an Abstract Class for my DataTables Common Code.  This class Inherits from DataTable. Also, it can …
It’s quite interesting for me as I worked with Excel using vb.net for some time. Here are some topics which I know want to share with others whom this might help. First of all if you are working with Excel then you need to Download the Following …
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…

771 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

11 Experts available now in Live!

Get 1:1 Help Now