'Date' databinding

  • Thread starter Thread starter Agnes
  • Start date Start date
A

Agnes

The following gived by Cor work great.
However, as I put them in "form_load", the textbox ALWAYS show the time
also.
After I move the position of the table, it will show "according to my
setting " (yyyy/MM/dd) "
I try to put Me.refresh , in form_load, but it seems useless. Thanks in
advance

private sub load
Me.txtTransDate.DataBindings.Add("Text", dsSeaInvInfo,
"InvoiceHeader.transdate")
AddHandler txtTransDate.DataBindings("Text").Format, AddressOf
DBdateTextbox
AddHandler txtTransDate.DataBindings("Text").Parse, AddressOf
TextBoxDBdate
end load
Private Sub DBdateTextbox(ByVal sender As Object, ByVal cevent As
ConvertEventArgs)
If cevent.Value Is DBNull.Value Then
cevent.Value = ""
Else
Dim datum As Date
datum = CDate(cevent.Value)
cevent.Value = datum.ToString("yyyy/MM/dd")
End If
End Sub
Private Sub TextBoxDBdate(ByVal sender As Object, ByVal cevent As
ConvertEventArgs)
If cevent.Value.ToString = "" Then
cevent.Value = DBNull.Value
End If
End Sub
 
Hi,

I over came that problem by placing a label over the textbox and
then hiding it. It forces the textbox to get the value from the data source
and the format event is fired that time.

Ken
--------------------------
The following gived by Cor work great.
However, as I put them in "form_load", the textbox ALWAYS show the time
also.
After I move the position of the table, it will show "according to my
setting " (yyyy/MM/dd) "
I try to put Me.refresh , in form_load, but it seems useless. Thanks in
advance

private sub load
Me.txtTransDate.DataBindings.Add("Text", dsSeaInvInfo,
"InvoiceHeader.transdate")
AddHandler txtTransDate.DataBindings("Text").Format, AddressOf
DBdateTextbox
AddHandler txtTransDate.DataBindings("Text").Parse, AddressOf
TextBoxDBdate
end load
Private Sub DBdateTextbox(ByVal sender As Object, ByVal cevent As
ConvertEventArgs)
If cevent.Value Is DBNull.Value Then
cevent.Value = ""
Else
Dim datum As Date
datum = CDate(cevent.Value)
cevent.Value = datum.ToString("yyyy/MM/dd")
End If
End Sub
Private Sub TextBoxDBdate(ByVal sender As Object, ByVal cevent As
ConvertEventArgs)
If cevent.Value.ToString = "" Then
cevent.Value = DBNull.Value
End If
End Sub
 
Back
Top