Dear Cor,
I just try it.. [I overwrite the date to 16-07-2004 ,after press button
, it changed back >_< ]
Anyway, thanks for your kind help and coding.
I will try my best to search thr internet and seek the solution.
Thanks in advance
From Agnes
"Cor Ligthert" <(E-Mail Removed)> 秎ン
news:%(E-Mail Removed) い级糶...
> Hi Agnes,
>
> Can you try this sample, it needs one textbox and one button on a form.
>
> I hope this helps?
>
> Cor
>
> \\\
> Dim dt As New DataTable
> Private Sub Form4_Load(ByVal sender As Object, _
> ByVal e As System.EventArgs) Handles MyBase.Load
> dt.Columns.Add(New DataColumn("mydate", GetType(System.DateTime)))
> dt.Rows.Add(dt.NewRow)
> Dim Mybinding As New Binding("Text", dt, "mydate")
> TextBox1.DataBindings.Add(Mybinding)
> AddHandler Mybinding.Format, AddressOf DBdateTextbox
> AddHandler Mybinding.Parse, AddressOf TextBoxDBdate
> dt.Rows(0)("mydate") = New Date(2004, 7, 15)
> End Sub
> 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("dd - MM - yyyy")
> 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
> Private Sub Button1_Click(ByVal sender As System.Object, _
> ByVal e As System.EventArgs) Handles Button1.Click
> BindingContext(dt).EndCurrentEdit()
> MessageBox.Show(dt.Rows(0)(0).ToString)
> End Sub
> ///
>
>
|