Re: DataBinding.Format still the only way to format Textbox text?
"Pardee, Roy" <[email protected]>
| Newsgroups | gmane.comp.windows.devel.dotnet.winforms |
|---|---|
| Message-ID | <[email protected]> |
Oooh--that looks very promising. I shall investigate... Thanks! -----Original Message----- From: Discussion forum for developers using Windows Forms to build apps and controls [mailto:[email protected]] On Behalf Of Fabian Schmied Sent: Tuesday, May 08, 2007 4:08 AM To: [email protected] Subject: Re: [DOTNET-WINFORMS] DataBinding.Format still the only way to format Textbox text? > I'm coming back to winforms after a long hiatus, and now doing 2.0. > Back in the 1.1 days if I bound a Textbox.Text property to a DateTime > & I didn't want the time portion displayed, I'd have to handle the > appropriate DataBinding.Format event. Is that still the case in 2.0, > or is there some new cool way of specifying a display/input format for > that? I'm no expert on data binding, but a quick experiment yielded the following: Binding binding = new Binding ("Text", _source, "DateTimeMember"); binding.FormattingEnabled = true; binding.FormatString = "d"; textBox1.DataBindings.Add (binding); (There's also a Format event on the Binding class.) Regards, Fabian