.net textbox what is correct event to use.

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

When a user changes the text in a textbox i wish to update the registry key it represents. If I use event TextChanged event then as you type every character in your update the registry routines are called. If I use Validated Event then if you click on the text box or tab past it and not change the text the registry is refreshed. Is there an event that represents "I have changed this text and I have finished changing it now". (Apart from a button next to the text box "Update Registry" :-)
 
Hi,
AFAIK, there is no such event in .net.
But there is a work around
Use both two events.
Have a dirty flag.
set the dirty flat to true during the TextChanged event.
In the Validated Event, check the dirty flag and call the update registry
method.

Regards,
R.Balaji

Jarrod Sharp said:
When a user changes the text in a textbox i wish to update the registry
key it represents. If I use event TextChanged event then as you type every
character in your update the registry routines are called. If I use
Validated Event then if you click on the text box or tab past it and not
change the text the registry is refreshed. Is there an event that
represents "I have changed this text and I have finished changing it now".
(Apart from a button next to the text box "Update Registry" :-)
 
i think the Modified property of the TextBox control is my solution (like the dirty flag suggested). you have to manually reset it. here is what i am using:

Private Sub txtServer_Validated(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtServer.Validated
If txtServer.Modified Then
txtServer.Modified = False
ra = New RegistryAccess
ra.PutKey(ra.RegistryKeys.DatabaseServer, txtServer.Text)
ra = Nothing
End If
End Sub
 
Why don't you monitor the key press event and, for example, on Enter key you
save the value you want?

Jarrod Sharp said:
i think the Modified property of the TextBox control is my solution (like
the dirty flag suggested). you have to manually reset it. here is what i
am using:
Private Sub txtServer_Validated(ByVal sender As System.Object, ByVal e
As System.EventArgs) Handles txtServer.Validated
If txtServer.Modified Then
txtServer.Modified = False
ra = New RegistryAccess
ra.PutKey(ra.RegistryKeys.DatabaseServer, txtServer.Text)
ra = Nothing
End If
End Sub
key it represents. If I use event TextChanged event then as you type every
character in your update the registry routines are called. If I use
Validated Event then if you click on the text box or tab past it and not
change the text the registry is refreshed. Is there an event that
represents "I have changed this text and I have finished changing it now".
(Apart from a button next to the text box "Update Registry" :-)
 
Back
Top