Thanks for both replies! I don't like what I did to go around this,
but it works. I set the CausesValidation of the field to False and
then I put an event on lost focus that validates that the value is
numeric. If it isn't, the value is erased and the user is given an
error.
Private Sub PriceTextBox_LostFocus(ByVal sender As Object, ByVal e As
System.EventArgs) _
Handles PriceTextBox.LostFocus
If Not PriceTextBox.Text = "" Then
If Not IsNumeric(PriceTextBox.Text) Then
MessageBox.Show("A numeric value is required in this
field!", _
"Field requires numeric value!")
PriceTextBox.Text = ""
PriceTextBox.Focus()
End If
End If
End Sub
On Mar 17, 1:51 pm, Neo <[email protected]> wrote:
> The reason behind the the "Un-expected" behavior is very much
> expected,
> as the Textbox control is bound to the datasource and by default the
> CausesValidation
> property of the Textbox control is true, when ever the text value of
> the Textbox control is
> changed, it causes the control to validate the data, when you erase
> the text, the value
> inside the control is modified, hence forces the control to validate
> the data, since the value is empty,
> which fails the currency validation check, the focus won't change.
>
> Now you know the reason, post a workaround !! :)
>
> On Mar 16, 6:40 pm, Gojavid <[email protected]> wrote:
>
> > Good morning,
>
> > I'm a newbie, so I fully expect that this is a simple issue.
>
> > I have a databound textbox that binds to an Access database field,
> > Price (currency). The control works fine when nothing is entered into
> > it at all, however if the textbox.text is changed whatsoever the focus
> > can't be changed unless a valid number is entered.
>
> > So, for instance, I entered "hello" into the textbox and pressed tab.
> > The focus won't change, that doesn't surprise me at all, but then I
> > erased the text and tried to tab out, and it wouldn't allow it. If I
> > then change the text to a number, I can tab or click out of the
> > control.
>
> > Does anyone have any ideas?
To unsubscribe from this group, send email to
dotnetdevelopment+unsubscribegooglegroups.com or reply to this email with the
words "REMOVE ME" as the subject.