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 6026957
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T04:31:13+00:00 2026-05-23T04:31:13+00:00

im using a textbox and need to replace text in the textbox. the problem

  • 0

im using a textbox and need to replace text in the textbox. the problem is that i need to replace 718 different items. I would like to put each replace into its own thread to quicken the process but when i do, it never replaces.

i have tried similar to the following

foreach (Match m in matchCollection)
{
ReplaceClass r = new ReplaceClass(TextBox,m,ReplaceText)
Thread th = new Thread(new ThreadStart(r.Replace))
th.start()
}
  • 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-05-23T04:31:14+00:00Added an answer on May 23, 2026 at 4:31 am

    As Dyppl wrote in a comment you can access a form only from the thread in wich it was declared and it’s running.
    I think that if you want to speed up the process don’t replace the text in the text box but just copy the text in a temporary string , modify it (replace the matches ) and then overwrite the text in the form.
    So

    string text = TextBox.Text
    foreach (Match m in matchCollection)
    {
       text = somereplacement(m,replacetext);
    
    }
    TextBox.Text = text;
    

    Edit:
    As the Anthony Pegram says , it’s not good to manipulate a string in such way inside a loop because the string gets created every time , but i don’t know what your replace function does. A better way could be

    StringBuilder text = new StringBuilder(TextBox.Text);  
    foreach (Match m in matchCollection)
    {
       //do something
       .
       .
       .
       text.Replace( toreplace ,replacement);
    
    }
    TextBox.Text = text.toString();
    

    Or you can also use the functions to search and replace of regular expressions. Just don’t replace over the textbox because each time you make a replacement the control has to be drawn again.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Using C#, when a user types a text in a normal textbox, how can
Using asp.net MVC I'd like to do this inside a view: <%= Html.TextBox(textbox1, null,
I need something like TextBox like Label for RadioButton content. I have made all
I have a textbox with default text like Enter Name Once user starts typing
Has anyone used jQuery to populate an autocomplete list on a textbox using ASP.NET
I am using the Html.TextBox helper to create textboxes. I want to set attributes
Hi there im using a single TextBox for querying differents types of chossings, for
Possible Duplicate: Watermarked Textbox for Compact Framework Using Visual Studio 2008 SP1, the latest
I am using a dropdown to populate a textbox. But if preferred value is
I've got this textBox which triggers off an ajax request using jQuery: <asp:TextBox ID=postcodeTextBox

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.