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

Check for Changes

P: n/a
Hi

I have a form with multiple text fields and need a way of checking to see if
changes are made in any of them I know I could use the keypress on each box
but there must be an easier way.

Thanks in advance.

Mike.

Nov 20 '05 #1
Share this Question
Share on Google+
6 Replies


P: n/a
Textbox.Modified?

Rgds,
Anand
VB.NET MVP
http://www.dotnetindia.com

"Michael Turner" wrote:
Hi

I have a form with multiple text fields and need a way of checking to see if
changes are made in any of them I know I could use the keypress on each box
but there must be an easier way.

Thanks in advance.

Mike.

Nov 20 '05 #2

P: n/a
>I have a form with multiple text fields and need a way of checking to see if
changes are made in any of them I know I could use the keypress on each box
but there must be an easier way.


Have a look at the TextChanged event.

Cheers

Blu
Nov 20 '05 #3

P: n/a
I see what you mean but I was hoping for a more global command that would
allow me to say if anything was modified on the form then it would run
rather than add code to each textbox.

Mike.

"Anand[MVP]" <An******@discussions.microsoft.com> wrote in message
news:42**********************************@microsof t.com...
Textbox.Modified?

Rgds,
Anand
VB.NET MVP
http://www.dotnetindia.com

"Michael Turner" wrote:
Hi

I have a form with multiple text fields and need a way of checking to see if changes are made in any of them I know I could use the keypress on each box but there must be an easier way.

Thanks in advance.

Mike.


Nov 20 '05 #4

P: n/a
* "Michael Turner" <fi*****@m-turner.co.uk> scripsit:
I have a form with multiple text fields and need a way of checking to see if
changes are made in any of them I know I could use the keypress on each box
but there must be an easier way.


Loop through the textboxes and add a handler to their 'ModifiedChanged'
event.

--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>
Nov 20 '05 #5

P: n/a
Write a single function that handles TextChanged Event for all textboxes. So that will run whenever any textbox is changed and focus is shifted to the next control.

Rgds,
Anand
VB.NET MVP
http://www.dotnetindia.com

"Michael Turner" wrote:
I see what you mean but I was hoping for a more global command that would
allow me to say if anything was modified on the form then it would run
rather than add code to each textbox.

Mike.

"Anand[MVP]" <An******@discussions.microsoft.com> wrote in message
news:42**********************************@microsof t.com...
Textbox.Modified?

Rgds,
Anand
VB.NET MVP
http://www.dotnetindia.com

"Michael Turner" wrote:
Hi

I have a form with multiple text fields and need a way of checking to see if changes are made in any of them I know I could use the keypress on each box but there must be an easier way.

Thanks in advance.

Mike.


Nov 20 '05 #6

P: n/a
Hi,

Here is how you can check all the controls on the form.
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click

CheckIfDirty(Me.Controls)

End Sub

Private Sub CheckIfDirty(ByVal ctrls As Control.ControlCollection)

For Each ctrl As Control In ctrls

If TypeOf ctrl Is TextBox Then

If DirectCast(ctrl, TextBox).Modified Then

Dim strOut As String

strOut = String.Format("{0} is dirty", DirectCast(ctrl, TextBox).Name)

Trace.WriteLine(strOut)

End If

End If

'

' check child controls if any

'

CheckIfDirty(ctrl.Controls)

Next

End Sub

Ken

-----------------------

"Michael Turner" <fi*****@m-turner.co.uk> wrote in message
news:uk**************@TK2MSFTNGP11.phx.gbl...
I see what you mean but I was hoping for a more global command that would
allow me to say if anything was modified on the form then it would run
rather than add code to each textbox.

Mike.

"Anand[MVP]" <An******@discussions.microsoft.com> wrote in message
news:42**********************************@microsof t.com...
Textbox.Modified?

Rgds,
Anand
VB.NET MVP
http://www.dotnetindia.com

"Michael Turner" wrote:
> Hi
>
> I have a form with multiple text fields and need a way of checking to see if > changes are made in any of them I know I could use the keypress on each box > but there must be an easier way.
>
> Thanks in advance.
>
> Mike.
>
>
>
>


Nov 20 '05 #7

This discussion thread is closed

Replies have been disabled for this discussion.