all groups > dotnet compact framework > april 2005 >
You're in the

dotnet compact framework

group:

Why is my bound form not clearing?!?!


Why is my bound form not clearing?!?! Mike
4/30/2005 8:19:01 PM
dotnet compact framework:
I am having some strange behavior trying to clear some textboxes on a form
that is bound to a datatable. The bizarre thing is that I have about 10
bound text boxes on my form, but I am only having trouble with two of them.
I have a button on my form, that when pushed, needs to clear the contents of
all the fields. So I enter values in all my textboxes and use the following
code to clear the textboxes.


For i = 0 To Me.Controls.Count - 1

If TypeOf (Me.Controls(i)) Is TextBox Then
Me.Controls(i).Text = Nothing
End If

Next

At this point, all the values clear from the form. But, when I End the
Current Edit via...

Me.BindingContext(datatable).EndCurrentEdit()

Two of my textboxes reinsert the values they had in there before they were
cleared, all of the other textboxes clear fine. I have tried renaming the
textboxes, deleting and reinserting them, nothing seems to work. Same two
textboxes everytime. For that matter, I try to clear the contents using the
SIP, but the numbers will not go away. Anybody have any suggestions?

Thanks!

Mike

Re: Why is my bound form not clearing?!?! Ilya Tumanov [MS]
5/1/2005 2:28:34 PM
Consider clearing the data source instead.



Best regards,



Ilya



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


[quoted text, click to view]

More Info.... Mike
5/1/2005 6:52:01 PM
OK, I have figured out that the two fields I am having trouble with just
happen to be Numeric DataTypes. It appears that a Numeric Datatype cannot be
Nothing or "" which is why it keeps reseting back to the value before it was
cleared. Therefore, my question just became a bit simpler.....

How do I assign a numeric textbox a value of nothing?

Thanks!

Mke

[quoted text, click to view]
Re: More Info.... ctacke/
5/2/2005 7:22:56 AM
As Ilya suggested, clear the data source.

-Chris

[quoted text, click to view]

Re: More Info.... Mike
5/2/2005 10:40:02 AM
Thanks guys. I'm trying to figure out exactly what you are suggesting in
clearing the data source. I cant clear my datatable because I need that data
to remain loaded. I cant delete the row, because I still need to enter some
data for that row. Could you provide a quick code snippet as to what you
were envisioning? Thanks!




[quoted text, click to view]
Re: More Info.... Ilya Tumanov [MS]
5/2/2005 1:49:41 PM
I'm not suggesting deleting data from the data table or deleting the current
row.
I'm suggesting setting data in the current row to DBNull or some defaults.

Something like this:

Dim bmb As BindingManagerBase = Me.BindingContext(datatable)
Dim drv As DataRowView = CType(bmb.Current, DataRowView)


drv(0) = DBNull.Value ' Or set to default value
....

Best regards,

Ilya

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

[quoted text, click to view]

Re: More Info.... mike
5/2/2005 4:51:30 PM
Thanks Ilya. I see what you are saying now. It appears to work great!

FYI-strange thing, I cant see your posts via the MSDN Usenet group,
just via the Google groups? I can see everyone else's just not yours?

Anyway, thanks for the input!


[quoted text, click to view]
AddThis Social Bookmark Button