473,395 Members | 1,706 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

TextChanged

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
Nov 21 '05 #1
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

Nov 21 '05 #2
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
Nov 21 '05 #3
"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/>

Nov 21 '05 #4
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
Nov 21 '05 #5
"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/>

Nov 21 '05 #6
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
Nov 21 '05 #7
Don
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


Nov 21 '05 #8
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

Nov 21 '05 #9
"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/>

Nov 21 '05 #10
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
Nov 21 '05 #11
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/>

Nov 21 '05 #12
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
Nov 21 '05 #13
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/>

Nov 21 '05 #14


*** Sent via Developersdex http://www.developersdex.com ***
Nov 21 '05 #15

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
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...
4
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...
2
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?
2
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...
1
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...
2
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...
1
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....
5
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...
4
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...
1
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...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
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...
0
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
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
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...
0
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...
0
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...
0
jinu1996
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...
0
tracyyun
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...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.