By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,853 Members | 995 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,853 IT Pros & Developers. It's quick & easy.

Binding, Format, Parse...Not able to edit

P: n/a
I have some textboxes bound to an access db. I wanted to format the
textboxes that displayed currency and date info so I did the following:

Dim WithEvents oBidAmt As Binding
oBidAmt = New Binding("Text", Me.Ds1, "Items.BidAmt")
txtBidAmt.DataBindings.Add(oBidAmt)
Private Sub oBidAmt_Format(ByVal sender As Object, ByVal e As
System.Windows.Forms.ConvertEventArgs) Handles oBidAmt.Format
e.Value = Format(e.Value, "c")
End Sub

Private Sub oBidAmt_Parse(ByVal sender As Object, ByVal e As
System.Windows.Forms.ConvertEventArgs) Handles oBidAmt.Parse
e.Value = Format(e.Value, "D")
End Sub

I am unable to edit the textboxes that are currency formatted. I am able to
edit the textboxes that are date formatted.
When I type a new amount into a textbox with currency formatting it reverts
back to the old amount as soon as I leave the textbox.
The date types do however work as expected.

Any ideas?
Slonocode
Nov 20 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
Slonocode -

The databound textbox is actually throwing an error that you can't catch.
You need to revert the currency back into a format that the db can handle.
(usually accomplished by removing the dollar sign ($, for example))
hope that helps

Steve Stein
VB Team

This posting is provided "AS IS" with no warranties and confers no rights.

--------------------
| From: "Slonocode" <st*******************@yahoo.com>
| Newsgroups: microsoft.public.dotnet.languages.vb
| Subject: Binding, Format, Parse...Not able to edit
| Date: Fri, 16 Jan 2004 19:05:21 -0500
| Lines: 30
| Message-ID: <bu************@ID-137764.news.uni-berlin.de>
| NNTP-Posting-Host: pcp05008461pcs.sanarb01.mi.comcast.net (68.40.85.170)
| X-Trace: news.uni-berlin.de 1074297930 16380971 68.40.85.170 ([137764])
| X-Priority: 3
| X-MSMail-Priority: Normal
| X-Newsreader: Microsoft Outlook Express 6.00.2720.3000
| X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2727.1300
| Path:
cpmsftngxa07.phx.gbl!cpmsftngxa10.phx.gbl!TK2MSFTN GXA06.phx.gbl!TK2MSFTNGXA0
5.phx.gbl!TK2MSFTNGP08.phx.gbl!newsfeed00.sul.t-online.de!newsfeed01.sul.t-o
nline.de!t-online.de!fu-berlin.de!uni-berlin.de!pcp05008461pcs.sanarb01.mi.c
omcast.NET!not-for-mail
| Xref: cpmsftngxa07.phx.gbl microsoft.public.dotnet.languages.vb:173793
| X-Tomcat-NG: microsoft.public.dotnet.languages.vb
|
| I have some textboxes bound to an access db. I wanted to format the
| textboxes that displayed currency and date info so I did the following:
|
| Dim WithEvents oBidAmt As Binding
| oBidAmt = New Binding("Text", Me.Ds1, "Items.BidAmt")
| txtBidAmt.DataBindings.Add(oBidAmt)
|
|
| Private Sub oBidAmt_Format(ByVal sender As Object, ByVal e As
| System.Windows.Forms.ConvertEventArgs) Handles oBidAmt.Format
| e.Value = Format(e.Value, "c")
| End Sub
|
| Private Sub oBidAmt_Parse(ByVal sender As Object, ByVal e As
| System.Windows.Forms.ConvertEventArgs) Handles oBidAmt.Parse
| e.Value = Format(e.Value, "D")
| End Sub
|
|
|
| I am unable to edit the textboxes that are currency formatted. I am able
to
| edit the textboxes that are date formatted.
| When I type a new amount into a textbox with currency formatting it
reverts
| back to the old amount as soon as I leave the textbox.
| The date types do however work as expected.
|
| Any ideas?
| Slonocode
|
|
|

Nov 20 '05 #2

P: n/a
""Steven Stein [MSFT]"" <ss****@online.microsoft.com> wrote in message
news:Nv**************@cpmsftngxa07.phx.gbl...
Slonocode -

The databound textbox is actually throwing an error that you can't catch.
You need to revert the currency back into a format that the db can handle.
(usually accomplished by removing the dollar sign ($, for example))
hope that helps

Steve Stein
VB Team

This posting is provided "AS IS" with no warranties and confers no rights.


I thought I was converting back to decimal with the Parse event. Am I using
the Parse/Format correctly? Do I have to manually remove the "$"?
Private Sub oBidAmt_Format(ByVal sender As Object, ByVal e As
System.Windows.Forms.ConvertEventArgs) Handles oBidAmt.Format
e.Value = Format(e.Value, "c")
End Sub

Private Sub oBidAmt_Parse(ByVal sender As Object, ByVal e As
System.Windows.Forms.ConvertEventArgs) Handles oBidAmt.Parse
e.Value = Format(e.Value, "D")
End Sub

Nov 20 '05 #3

P: n/a


Slonocode

You are correct. You need to convert back to decimal from the currency
string in the parse event. Here's a code snippet from the Binding.Parse
topic

http://msdn.microsoft.com/library/en...windowsformsbi
ndingclassparsetopic.asp
Private Sub CurrencyStringToDecimal(sender As Object, cevent As
ConvertEventArgs)
' The method converts back to decimal type only.
If Not cevent.DesiredType Is GetType(Decimal) Then
Exit Sub
End If

' Convert the string back to decimal using the shared Parse method.
cevent.Value = Decimal.Parse(cevent.Value.ToString, _
NumberStyles.Currency, nothing)

End Sub
hope that helps

Steve Stein
VB Team

This posting is provided "AS IS" with no warranties and confers no rights.

--------------------
From: "Slonocode" <su**********@spamsux.net>
Newsgroups: microsoft.public.dotnet.languages.vb
Subject: Re: Binding, Format, Parse...Not able to edit
Date: Tue, 20 Jan 2004 20:41:20 -0500
Lines: 32
Message-ID: <bu************@ID-137764.news.uni-berlin.de>
References: <bu************@ID-137764.news.uni-berlin.de> <Nv**************@cpmsftngxa07.phx.gbl>NNTP-Posting-Host: pcp05008461pcs.sanarb01.mi.comcast.net (68.40.85.170)
X-Trace: news.uni-berlin.de 1074649287 19687756 68.40.85.170 ([137764])
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2720.3000
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2727.1300
Path: cpmsftngxa07.phx.gbl!cpmsftngxa06.phx.gbl!TK2MSFTN GP08.phx.gbl!newsfeed00.su
l.t-online.de!newsfeed01.sul.t-online.de!t-online.de!fu-berlin.de!uni-berlin
.de!pcp05008461pcs.sanarb01.mi.comcast.NET!not-for-mailXref: cpmsftngxa07.phx.gbl microsoft.public.dotnet.languages.vb:174695
X-Tomcat-NG: microsoft.public.dotnet.languages.vb

""Steven Stein [MSFT]"" <ss****@online.microsoft.com> wrote in message
news:Nv**************@cpmsftngxa07.phx.gbl...
Slonocode -

The databound textbox is actually throwing an error that you can't catch.
You need to revert the currency back into a format that the db can handle. (usually accomplished by removing the dollar sign ($, for example))
hope that helps

Steve Stein
VB Team

This posting is provided "AS IS" with no warranties and confers no
rights.
I thought I was converting back to decimal with the Parse event. Am I usingthe Parse/Format correctly? Do I have to manually remove the "$"?
Private Sub oBidAmt_Format(ByVal sender As Object, ByVal e As
System.Windows.Forms.ConvertEventArgs) Handles oBidAmt.Format
e.Value = Format(e.Value, "c")
End Sub

Private Sub oBidAmt_Parse(ByVal sender As Object, ByVal e As
System.Windows.Forms.ConvertEventArgs) Handles oBidAmt.Parse
e.Value = Format(e.Value, "D")
End Sub


Nov 20 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.