PC Review


Reply
Thread Tools Rate Thread

Data binding a date to a text box

 
 
Paul Hester
Guest
Posts: n/a
 
      25th Jul 2005
I have a data binding issue that I was hoping someone could help me
with.

We have converted a VB6 app to .NET unsung a conversion tool that came
with .NET studio. Instead of converting the ADO code to ADO.NET it
used COM interop to call to continue to use ADO objects.

In the app sever date fields are bound to date data fields. In the old
app after data binding the date would show with just the date
(1/1/2000). After the app was converted the text boxes now show the
date and time (1/1/2000 12:00 AM). When I edit the text box by
deleting the time and TAB out of the field the binding immediatly adds
it back in.

I know that if we were to manually convert the app to use ADO.NET I
could attach to events on the Binding object that is put into the
TextBox.DataBindings collection
(http://www.kdkeys.net/forums/715/ShowPost.aspx). However due to
budget constraints this is not feasible.

I have checked all the properties and events on the textbox and ADO
bindings to try to get the time out of the text box with no success.

Is there any way I can get the time out of the text box using ADO
through COM interop?

 
Reply With Quote
 
 
 
 
=?Utf-8?B?QU1ESVJU?=
Guest
Posts: n/a
 
      25th Jul 2005
Here is what I did for a similar issue. I formatted the value as
ToShortDateString

'In the binding routine
b = New Binding("Text", dr, "EffectiveDate")
AddHandler b.Parse, AddressOf DataBindingManager.CurrencyStringtoDate
AddHandler b.Format, AddressOf DataBindingManager.DateToCurrencyString
Me.txtEffectiveDate.DataBindings.Add(b)

'Handler for binding format
Public Shared Sub DateToCurrencyString(ByVal sender As Object, ByVal e As
System.windows.forms.ConvertEventArgs)

If e.Value Is System.DBNull.Value Then
e.Value = ""
Else
e.Value = CType(e.Value, Date).ToShortDateString.ToString
End If

End Sub


"Paul Hester" wrote:

> I have a data binding issue that I was hoping someone could help me
> with.
>
> We have converted a VB6 app to .NET unsung a conversion tool that came
> with .NET studio. Instead of converting the ADO code to ADO.NET it
> used COM interop to call to continue to use ADO objects.
>
> In the app sever date fields are bound to date data fields. In the old
> app after data binding the date would show with just the date
> (1/1/2000). After the app was converted the text boxes now show the
> date and time (1/1/2000 12:00 AM). When I edit the text box by
> deleting the time and TAB out of the field the binding immediatly adds
> it back in.
>
> I know that if we were to manually convert the app to use ADO.NET I
> could attach to events on the Binding object that is put into the
> TextBox.DataBindings collection
> (http://www.kdkeys.net/forums/715/ShowPost.aspx). However due to
> budget constraints this is not feasible.
>
> I have checked all the properties and events on the textbox and ADO
> bindings to try to get the time out of the text box with no success.
>
> Is there any way I can get the time out of the text box using ADO
> through COM interop?
>
>

 
Reply With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Data binding a text box si_owen Microsoft VB .NET 1 13th Oct 2006 03:50 PM
data binding and text box =?Utf-8?B?YWx5c3Nh?= Microsoft C# .NET 2 16th Mar 2005 03:20 AM
Binding data to a text box =?Utf-8?B?Y2hyaXM=?= Microsoft ASP .NET 1 21st Jul 2004 01:46 PM
[data binding ] set the date format in the textbox. Agnes Microsoft VB .NET 1 16th May 2004 10:34 AM
Text Box and Data Binding Question Lance Geeck Microsoft VB .NET 0 5th Sep 2003 09:11 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 10:15 AM.