Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8328601
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T01:29:47+00:00 2026-06-09T01:29:47+00:00

I have a TextChanged event for my WPF TextBox as follows: private void textMatch_TextChanged(object

  • 0

I have a TextChanged event for my WPF TextBox as follows:

private void textMatch_TextChanged(object sender, TextChangedEventArgs e)
{
    var m = e.Changes;//here I can see e.Changes has what I'm looking for
    //do some other stuff here.
}

However, what I want to do is to check the length of text that was added. Apparently, e.Changes contains that value but I can’t figure out a way to find it out programmatically neither could I find any example online.

My current way of checking this is by storing the current length each time text is changed and making sure the new length only increases by 1 but It’s sorta like hacking to me.

Has anyone tried this before? How do I find out the length of the added text using the TextChangedEventArgs? Thanks.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T01:29:48+00:00Added an answer on June 9, 2026 at 1:29 am

    What you’re looking for is how to extract the TextChange object from the e.Changes TextChange collection. The following should work:

    int added = e.Changes.ElementAt(0).AddedLength;
    

    However, if you want something that looks more specific you could use:

    int added = e.Changes.FirstOrDefault().AddedLength;
    

    Since e.Changes as far as I know at the moment will always contain a single TextChange item, I guess it will always be the first even in future implementations of the WPF TextBox.

    For Non-Linq implementation which seems really unnecessary to me you can use the following bulky code:

    var x = e.Changes.GetEnumerator();
    x.MoveNext();
    int added = x.Current.AddedLength;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a method private void textBoxPilot_TextChanged(object sender, TextChangedEventArgs e) { ... } where
I have an event handler for the TextBox.TextChanged event on a form of mine.
I have a TextBox that has the TextChanged event set declaratively. In some cases,
I have the following code: Private Sub txtFileFromLocation_TextChanged(ByVal sender As System.Object, ByVal e As
I have a TextBox with a TextChanged event wired up. In the end it
I have to do complex calculations on every textchange event of a WPF textbox
If I have a TextChanged event wired on an asp.net textbox, it will fire
I have a textbox in an aspx page that has a TextChanged event attached
in my WPF textbox i have validated it on following events TextChanged PreviewTextInput so
I have a bunch of textboxes on my asp.net page, and on TextChanged event,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.