StrataFrame Forum

MaskedTextBox

http://forum.strataframe.net/Topic576.aspx

By Larry Caylor - 2/27/2006

There appears to be a problem with the MaskedTextBox. Binding a datetime field to the text box using the short date mask the results in the date 02/27/2006 being displayed as in the attached screen shot for DOB.
By StrataFrame Team - 2/28/2006

Howdy Larry,



I figured out your problem... .NET's data binding is just ToString()'ing the value that it's placing in the TextBox, and it's leaving off the leading 0. There's a BindingFormat property on the MaskedTextBox (right below the BindingField where you choose the field on the BO to bind to). In that BindingFormat property put this value "dd/MM/yyyy" and that should fix your problem. You can specify the format used on any binding by setting this property. It's the same as calling ToString("dd/MM/yyyy") rather than just ToString().



If you want more info on the date formats, you can go to this article within your VisualStudio help:



ms-help://MS.VSCC.v80/MS.MSDN.v80/MS.NETDEVFX.v20.en/cpref2/html/M_System_DateTime_ToString.htm



(the link might also work in IE, but I'm not positive on that Smile)
By Larry Caylor - 2/28/2006

Thanks Ben, that fixed the problem. I was looking at the "Mask" property and didn't even notice "BindingFormat".

-Larry

By StrataFrame Team - 2/28/2006

I never use the BindingFormat property, but I knew I exposed it for a reason, now I know why Smile
By Keith Chisarik - 11/1/2006

Great post! I was going nutz on this issue, glad it wasnt just me.



Also, can we get the default BindingUpdateMode changed from OnValidation to OnPropertyChanged for MaskedTextBox control?



Thanks
By Trent L. Taylor - 11/1/2006

Also, can we get the default BindingUpdateMode changed from OnValidation to OnPropertyChanged for MaskedTextBox control?

Done. Smile  This will be in the next release.