Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C# Events format WinForm , +
I am looking for a way to display other data in a MaskedTextBox than the data it is bound to (DataTable).
 
More specifically: The DataTable contains a DateTime column (DateOfBirth). Whenever the year is 1900, I would like to display it as empty in the MaskedTextBox while keeping it in the underlying DataTable, because I use 1900 for "unknown".
 
Example: Value in the DataTable: 1900-10-09 --[DataBinding]--> MaskedTextBox __-10-09
 
Currently, I am using the CurrentItemChanged-Event of the BindingSource to modify the Text-property of the MaskedTextBox. That works nicely as long as I simply browse through the DataTable. However, as soon as I start editing the MaskedTextBox, 1900 is back.
 
It would be nicer if I could somehow intercept the value that is passed from the DataRow to the MaskedTextBox, instead of replacing it afterwards.
 
Or maybe there is a way to get the MaskedTextBox to display 1900 as empty?
 
I have already asked the same question at stackoverflow, but so far, nobody new an answer - at least not for Windows Forms:
stackoverflow
 
So, if somebody knows an answer here, it will be greatly appreciated!
 
Thank you very much and best regards
-spitfire
Posted 1-Feb-12 7:26am

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

  Permalink  
Comments
spitfire_ch at 1-Feb-12 20:42pm
   
That's exactly the kind of events I have been looking for - but apparently, I have been blind! Thank you very much! :)
 
Best regards
spitfire_ch

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 OriginalGriff 230
1 Sergey Alexandrovich Kryukov 104
2 Richard MacCutchan 100
3 kbrandwijk 75
4 Vinay Mistry 70
0 Sergey Alexandrovich Kryukov 9,040
1 OriginalGriff 8,121
2 CPallini 2,613
3 Richard MacCutchan 2,221
4 Abhinav S 1,928


Advertise | Privacy | Mobile
Web01 | 2.8.140827.1 | Last Updated 1 Feb 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100