TextBox.TextChanged Event fires even when the text is changed
programatically. How can I detect that the text has been changed by the user
and not changed programatically?
Thanks 14 2713
Hi look at the
Keydown or keyup event
Greetz Peter
"Nice Chap" <Ni******@PlasmaDyne.com> schreef in bericht
news:e8**************@tk2msftngp13.phx.gbl... TextBox.TextChanged Event fires even when the text is changed programatically. How can I detect that the text has been changed by the
user and not changed programatically?
Thanks
Nice Chap,
Two ways.
Set a Boolean switch to evaluate that in the event
or
delete the handler when you do it programmatically
When you do it programmatically (and set it (back) afterwards)
I hope this helps,
Cor
"Nice Chap" <Ni******@PlasmaDyne.com> schrieb: TextBox.TextChanged Event fires even when the text is changed programatically. How can I detect that the text has been changed by the user and not changed programatically?
You may want to set a flag (for example, by setting the control's 'Tag'
property) before changing the value programmatically and check this flag in
the 'TextChanged' event handler.
--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>
Herfried, You may want to set a flag (for example, by setting the control's 'Tag' property)
Is using that tag for that an idea from VBCom (I saw Larry once doing that),
I don't see the benefit from it.
However maybe can you explain that too me(serious)
Cor
"Cor Ligthert" <no************@planet.nl> schrieb: You may want to set a flag (for example, by setting the control's 'Tag' property)
Is using that tag for that an idea from VBCom (I saw Larry once doing that), I don't see the benefit from it.
However maybe can you explain that too me(serious)
Using the 'Tag' property might be easier because you don't need any
additional private variables. However, it's one of many possible solutions
and its up to personal preference whether to use 'Tag' or not.
--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>
Herfried,
I find (and found it forever) wrong to use datafields that have no
descriptive names only to save 1 machineword. (that forever was a while
after the time that I was using relays, however than we could not give that
relay a descriptive name). However it sounds for me a behaviour from that
time.
I hope you agree that.
Cor
Don't forget the MouseDown/MouseUp events, in case the user pastes text by
right-clicking and selecting Paste on the popup menu (if any).
"Peter Proost" <pp*****@nospam.hotmail.com> wrote in message
news:%2****************@tk2msftngp13.phx.gbl... Hi look at the
Keydown or keyup event
Greetz Peter
"Nice Chap" <Ni******@PlasmaDyne.com> schreef in bericht news:e8**************@tk2msftngp13.phx.gbl... TextBox.TextChanged Event fires even when the text is changed programatically. How can I detect that the text has been changed by the user and not changed programatically?
Thanks
Ok, I've read all of the other responses, but I have to ask: "Why do you have to tell it
to do anything."
Simply Dim a "global" variable as a string and then do this:
Private Sub TextBox1_TextChanged(ByVal sender As System.Object, ByVal e As _
System.EventArgs) Handles TextBox1.TextChanged
myvariable = TextBox1.Text
End Sub
it detects any changes.
Or is there something wrong with doing this.??
--
Steve Easton
Microsoft MVP FrontPage
95isalive
This site is best viewed..................
...............................with a computer
"Nice Chap" <Ni******@PlasmaDyne.com> wrote in message
news:e8**************@tk2msftngp13.phx.gbl... TextBox.TextChanged Event fires even when the text is changed programatically. How can I detect that the text has been changed by the user and not changed programatically?
Thanks
"95isalive" <ad***@95isalive.com> schrieb; Ok, I've read all of the other responses, but I have to ask: "Why do you have to tell it to do anything."
Simply Dim a "global" variable as a string and then do this:
Private Sub TextBox1_TextChanged(ByVal sender As System.Object, ByVal e As _ System.EventArgs) Handles TextBox1.TextChanged
myvariable = TextBox1.Text
End Sub
it detects any changes.
Or is there something wrong with doing this.??
Well, the OP wants tol execute the code 'myvariable = TextBox1.Text' only if
the text has been changed by the user and not when it was changed
programmatically.
\\\
Private Sub TextBox1_TextChanged( _
ByVal sender As Object, _
ByVal e As EventArgs _
) Handles TextBox1.TextChanged
If Not DirectCast(sender, Control).Tag Then
...
End If
End Sub
..
..
..
With Me.TextBox1
.Tag = True
.Text = "Hello World!"
.Tag = False
End With
///
--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>
Or making it in my opinion as syntax nicer using Herfrieds sample
dim SwProramTextBox1Change as boolean
Private Sub TextBox1_TextChanged( _
ByVal sender As Object, _
ByVal e As EventArgs _
Handles TextBox1.TextChanged
If Not SwProgramTextBox1Change Then
...
End If
SwProgramChange = False
End Sub
///
\\\
SwProgramTextbox1Change = True
MeTextBox1.Text = "Hello World!"
///
:-)
Cor
Cor,
"Cor Ligthert" <no************@planet.nl> schrieb: Or making it in my opinion as syntax nicer using Herfrieds sample
dim SwProramTextBox1Change as boolean Private Sub TextBox1_TextChanged( _ ByVal sender As Object, _ ByVal e As EventArgs _ Handles TextBox1.TextChanged If Not SwProgramTextBox1Change Then ... End If SwProgramChange = False End Sub /// \\\ SwProgramTextbox1Change = True MeTextBox1.Text = "Hello World!" ///
I thought about resetting the flag inside the 'TextChanged' event handler
too but then decided not to do that. By letting the user reset the
property/flag manually consecutive changes of the textbox's content are
possible.
\\\
With Me.TextBox1
.Tag = True
For i = 1 To 20
...
If ... Then
.Text = ...
End If
Next i
.Tag = False
End With
///
The code above will not execute the code in the 'TextChanged' event handler
even if the textbox' text is changed more than once.
Just my 2 Euro cents...
--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>
Herfried,
My main thing is that using a Tag (just because it is there) for what it is
not created for is in my opinion not right. (You know it is friday evening
and you know what that means, so I don't go in discussion anymore)
I think you are right about the side effect what you wrote. However don't
shoot me at the moment when I did understand you wrong.
:-))
Cor
Cor,
"Cor Ligthert" <no************@planet.nl> schrieb: My main thing is that using a Tag (just because it is there) for what it is not created for is in my opinion not right. (You know it is friday evening and you know what that means, so I don't go in discussion anymore)
Mhm... I don't think that the use of 'Tag' shown in my sample is that bad,
but as I already said, I accept that other people choose another solution.
I think you are right about the side effect what you wrote. However don't shoot me at the moment when I did understand you wrong.
:-)
--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/> This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Fabrício de Novaes Kucinskis |
last post by:
Hi all,
I have a combobox control, in wich I put an autocomplete code. This code is
in the TextChanged event, but when this event fires, the Text property isn't
updated yet.
For example, if...
|
by: Francesco |
last post by:
Hi all,
I am trying to make a UserControl with a TextBox in it.
I have to publish the TextChanged event of the inner TextBox, but I have
some trouble.
If I declare :
public event EventHandler...
|
by: jorge |
last post by:
Hello
I have the following situation: (everything is dynamic (controls.add))
1. Button.Init {
WasButtonClickFired = true
}
2. TextBox.TextChanged {
WasButtonClickFired?
|
by: Owin |
last post by:
Hi all,
I've created an User control. It's an extension of a textbox wich has some extra properties so that validation becomes a lot faster.
The control wordks great if autopostback is on. When...
|
by: Samuel Chan |
last post by:
I used the textchanged event of textbox and set the autopostback property to
true. The textchanged event should fire when the content of the textbox is
changed and user tab out of the textbox...
|
by: gaurav |
last post by:
hi,
I have a problem, How do i use TextChanged Event by clicking on Button.
When i changed the text in text box and moving the focus from there
then it is working but i have one calender popup...
|
by: Stan Sainte-Rose |
last post by:
Hi,
I have a problem with my textchanged and leave events
I have a script in the leave event of my textbox and also in my textchanged.
The script in my textchanged adds and displays a tabpage....
|
by: barry |
last post by:
The code below works fine for one textbox (hit enter key) but adding another
textbox and including the handle for it will not change either textbox
without switching the focus to say a button. Do...
|
by: Jason Huang |
last post by:
Hi,
In my C# Windows form MyForm I have some TextBoxes.
In these TextBoxes, we have to detect if the TextChanged event occurs,
if there're changes in these TextBoxes, it will ask if we want to...
|
by: jeeber |
last post by:
I saw this on another thread (Francesco November 15th, 2005 UserControl.TextChanged) but I didn't see how to add to the discussion, so I'm just starting a new one and hope that people find it.
The...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
| |