Questions tagged [textchanged]

An event that occurs when the text/content of a UI element has changed.

Definition:

The TextChanged event is an event that occurs when the text or content of a UI element has changed.

Most of the time this will be the text/content of a textbox. In general this event is not bound to a specific language or framework. The event can be captured in .NET, JAVA, JavaScript, ...

Examples:

  • .NET

    • WindowsForms

      TextBox _nameTextBox = new TextBox();
      _nameTextBox.TextChanged += new EventHandler(NameTextBox_TextChanged);
      
      private void NameTextBox_TextChanged(object sender, EventArgs e)
      {
          //Handle event
      }
      
    • WPF

      <TextBox TextChanged="MyTextBox_TextChanged">Default text</TextBox>
      
      private void MyTextBox_TextChanged(object sender, TextChangedEventArgs args)
      {
          //Handle event
      }
      
  • JAVA

    JTextField nameTextField = new JTextField();
    
    nameTextField .getDocument().addDocumentListener(new DocumentListener() {
    
        public void removeUpdate(DocumentEvent e) {
        }
    
        public void insertUpdate(DocumentEvent e) {
        }
    
        public void changedUpdate(DocumentEvent e) {
        }
    }); 
    
  • HTML/JavaScript

    <input type="text" id="name" onchange="nameChanged()">
    
    function nameChanged() {
        var name = document.getElementById("name");
        //Handle event
    }
    

More reading:

287 questions
77
votes
17 answers

How can I do something 0.5 seconds after text changed in my EditText control?

I am filtering my list using an EditText control. I want to filter the list 0.5 seconds after the user has finished typing in EditText. I used the afterTextChanged event of TextWatcher for this purpose. But this event rises for each character…
Bob
  • 22,810
  • 38
  • 143
  • 225
36
votes
4 answers

Why isn't this causing an infinite loop of events?

I have a simple application that reverses any text typed to it in another textbox. The catch is, you can modify either textbox and the changes will be (literally) reflected in the other. I wrote this code, believing for it to cause problems. private…
PurkkaKoodari
  • 6,703
  • 6
  • 37
  • 58
26
votes
2 answers

How to avoid getting both called: onItemClicked and onTextChanged on AutoCompleteTextView

I have this code. When I choose an item from suggestion list, the onTextChanged happens first, then oItemClicked comes after that. Now I want when choosing a word, the "onItemClicked" appears first, then "onTextChanged". I took a look Android doc…
emeraldhieu
  • 9,380
  • 19
  • 81
  • 139
17
votes
2 answers

What is the difference between TextUpdate and TextChanged Event?

for each control there are a lot of events, two are very similar such as Text Update and Text Changed, whis is the difference?
user3289840
  • 241
  • 1
  • 2
  • 10
15
votes
3 answers

Having TextChanged Event Fire Immediately as Text is Typed into TextBox

On a wpf TextBox that has an TextChanged event, it seems to only fires when focus is taken away from the textbox; but not as individual characters are typed in. Is there an event similar to TextChanged that fires immediately when a character is…
thecoop
  • 45,220
  • 19
  • 132
  • 189
13
votes
2 answers

Text Box Text Changed event in WPF

So, for example if I have 2 text boxes in WFA. The following code works. private void textBox1_TextChanged(object sender, EventArgs e) { textBox2.Text = textBox1.Text; } And I get this. The text in the second text box equals to the…
Roman
  • 1,267
  • 2
  • 13
  • 20
12
votes
4 answers

Detect Enter Key C#

I have the following code which does not show the MessageBox when enter/return is pressed. For any other key(i.e. letters/numbers) the MessageBox shows False. private void cbServer_TextChanged(object sender, EventArgs e) { if (enterPressed) …
k1f1
  • 433
  • 3
  • 8
  • 16
10
votes
2 answers

ASP.NET OnTextChanged not firing from inside an update panel

I am using an ASP.NET update panel to retrieve user info using the on TextChanged for the textbox, here is my code:
Wahtever
  • 3,597
  • 10
  • 44
  • 79
10
votes
5 answers

How to handle the TextChanged event only when the user stops typing?

I have a TextBox with a TextChanged event wired up. In the end it is making a query to a SQL database, so I want to limit the number of queries. I only want to make the query if the user hasn't pressed a key in say .. 300 milliseconds or so. If for…
esac
  • 24,099
  • 38
  • 122
  • 179
10
votes
5 answers

Disable firing TextChanged event

I have textbox and I'm changing the text inside it when lostFocus is fired but that also fires up the textChanged event, which I'm handling but I don't want it to be fired in this one case, how can I disable it here? UPDATE: The idea with bool is…
Ms. Nobody
  • 1,219
  • 3
  • 14
  • 34
9
votes
3 answers

How to use onQueryTextChange with many fragments

I have many fragments they're shown in 2 tab layouts using FragmentStatePagerAdapter in each fragment there is a Recycler view and I want to use a search bar in the app bar to filter results. First I did this using the onQueryTextChange listener in…
Martin Seal
  • 616
  • 2
  • 14
  • 32
9
votes
3 answers

Qt5: Tell QPlainTextEdit to ignore syntax highlighting changes

I have a QPlainTextEdit widget in my application which has a QSyntaxHighlighter assigned to it. Upon each content change within that text edit area, I need to get a notification (to update the global application save/changed state). However, the…
Philip Allgaier
  • 3,505
  • 2
  • 26
  • 53
7
votes
4 answers

onQueryTextChange triggered after app resume

I am stumbed with animated searchview onQueryTextListener. When activity and fragment created first it works nice. Then I press home button, open other apps, do some work there to wipe the data of searchview activity and then return to the app. And…
Alex Shcherbyna
  • 301
  • 4
  • 9
6
votes
2 answers

Why my textbox TextChanged event gets fired after I enter "only" one character in my text box?

private void NameVal_TextChanged(object sender, EventArgs e) { String text = NameVal.Text; } As soon as I enter the first letter of my Name this program gets executed . How do I make the program wait until I finish entering the…
user1298925
  • 2,304
  • 7
  • 29
  • 43
5
votes
2 answers

Java equivalent to C# TextBox TextChanged event

in C# there is an event for textboxes as follows private void fooText_TextChanged(object sender, EventArgs e) { //do something } the code in the fooText_TextChanged is fired once the text within the textbox is altered. What is the java…
Ari
  • 1,026
  • 6
  • 20
  • 31
1
2 3
19 20