|
dev
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
DateTime Bound to TextBoxHi,
I have bound a DateTime field in a DataTable to a TextBox field. Other String and Numeric fields are also bound to separate TextBoxes. If a new DataRow is created and a DateTime value is entered no problem. However, after the row is saved, I am unable to clear the date from the textbox. I do not have this problem when binding to a DataGrid. But a DataGrid is far from user friendly and just plain impractical in many situations. In its place I am loading the DataRow into a class and using unbound fields on the form. Bound controls seem great for strings. But thats about it. Does anyone have a better solution? Thanks Try writing Format and Parse event handlers for the binding to convert
empty string to empty datetime http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfSystemWindowsFormsBindingClassFormatTopic.asp http://www.akadia.com/services/dotnet_databinding.html#Format%20and%20Parse%20Events%20of%20the%20Binding%20Class http://www.eggheadcafe.com/ng/microsoft.public.dotnet.framework.windowsforms.databinding/post109933.asp Sijin Joseph http://www.indiangeek.net http://weblogs.asp.net/sjoseph mark wrote: Show quoteHide quote > Hi, > > I have bound a DateTime field in a DataTable to a TextBox field. Other > String and Numeric fields are also bound to separate TextBoxes. If a new > DataRow is created and a DateTime value is entered no problem. However, > after the row is saved, I am unable to clear the date from the textbox. > > I do not have this problem when binding to a DataGrid. But a DataGrid is > far from user friendly and just plain impractical in many situations. > > In its place I am loading the DataRow into a class and using unbound fields > on the form. Bound controls seem great for strings. But thats about it. > Does anyone have a better solution? > > Thanks > Sijin,
I'm a bit confused about the meaning of an empty DateTime. Are you saying set this field to DBNull in the Parse event? Because a DateTime cannot be set to null. The runtime throws an error. Thanks Show quoteHide quote "Sijin Joseph" wrote: > Try writing Format and Parse event handlers for the binding to convert > empty string to empty datetime > > http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfSystemWindowsFormsBindingClassFormatTopic.asp > > http://www.akadia.com/services/dotnet_databinding.html#Format%20and%20Parse%20Events%20of%20the%20Binding%20Class > http://www.eggheadcafe.com/ng/microsoft.public.dotnet.framework.windowsforms.databinding/post109933.asp > > Sijin Joseph > http://www.indiangeek.net > http://weblogs.asp.net/sjoseph > > mark wrote: > > Hi, > > > > I have bound a DateTime field in a DataTable to a TextBox field. Other > > String and Numeric fields are also bound to separate TextBoxes. If a new > > DataRow is created and a DateTime value is entered no problem. However, > > after the row is saved, I am unable to clear the date from the textbox. > > > > I do not have this problem when binding to a DataGrid. But a DataGrid is > > far from user friendly and just plain impractical in many situations. > > > > In its place I am loading the DataRow into a class and using unbound fields > > on the form. Bound controls seem great for strings. But thats about it. > > Does anyone have a better solution? > > > > Thanks > > >
Other interesting topics
Hidding a window and preventing Alt-Tabbing to it
Monitor Dial-up Connection find process by processname Deployed simple C#.NET single form application to Windows server 2003 and the form will not display, How to simply load a freeekin bitmap from a resource? Closing all instances of an application Panel & keyboard focus Hello, Japan? Creating VS Studio like control creating VS Studio like controls |
|||||||||||||||||||||||