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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 10, 20262026-05-10T22:46:48+00:00 2026-05-10T22:46:48+00:00

I’d like a textbox that allows for certain text within to be constant and

  • 0

I’d like a textbox that allows for certain text within to be ‘constant’ and uneditable while the rest of the text is editable. For instance, I’d like to define a template like this:

<Name:>[] <Address:>[] <City>:[] 

So that the user could later enter:

<Name:>[Stefan] <Address:>[Nowhere] <City>:[Alaska] 

But not:

<I'm typing here lol:>[Stefan] <Address:>[Nowhere] <State>:[Alaska] 

Ideally, they wouldn’t even be able to put their cursor in between the <>, similar to Microsoft Word templates.

Any ideas? The masked textbox control seems to be along the right path, but isn’t multiline and doesn’t allow you to enter a variable number of characters in between the braces, for instance.

Thanks in advance.

  • 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. 2026-05-10T22:46:49+00:00Added an answer on May 10, 2026 at 10:46 pm

    I don’t know of any ready-made components. But you could try this simple method.

    1. Create a normal multi-line text box control
    2. Create a regex-based template that has (.*) or ([a-z]*) or whatever wherever you want the user to add text.
    3. Whenever the text is changed, checked if it still matches the regex. If it does, accept the chagne. If it doesn’t, reject the change.

    You can then use the same regex to extract your data from the text box.

    You could even use a RichTextBox and use the regex to perform formatting.

    Update Here’s what I wrote. It seems to work:

    [DefaultProperty('Regex')] public partial class MaskedEdit : UserControl {     private Regex regex = new Regex('');     private bool myChange = false;      private string goodText;     private Font dataFont;      public MaskedEdit()     {         myChange = true;         InitializeComponent();         myChange = false;         dataFont = new Font(Font, FontStyle.Bold);         goodText = Text;     }      [Editor('System.ComponentModel.Design.MultilineStringEditor, System.Design', typeof(UITypeEditor)), Localizable(true)]     [DefaultValue('')]     public String Regex     {         get { return regex.ToString(); }         set         {             if (value != null)             {                 regex = new Regex(value);             }         }     }      [EditorBrowsable(EditorBrowsableState.Always)]     [Browsable(true)]      [Editor('System.ComponentModel.Design.MultilineStringEditor, System.Design', typeof(UITypeEditor)), Localizable(true)]     [DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)]     public override string Text     {         get { return rtf.Text; }         set {             int selSt = rtf.SelectionStart;             int selLen = rtf.SelectionLength;              rtf.Text = value;              rtf.SelectionStart = selSt;             rtf.SelectionLength = selLen;         }     }      private void rtf_TextChanged(object sender, EventArgs e)     {         if (myChange) return;         Match m = regex.Match(Text);         if (m.Success)         {             goodText = Text;             Colorize(m);         }         else         {             myChange = true;             Text = goodText;             myChange = false;             m = regex.Match(Text);             if (m.Success)             {                 Colorize(m);             }         }     }      public IEnumerable<string> Data     {         get         {             Match m = regex.Match(Text);             bool first = true;             foreach (Group g in m.Groups)             {                 if (first) { first = false; continue; }                 yield return Text.Substring(g.Index, g.Length);             }         }     }      private void Colorize(Match m)     {         int selSt = rtf.SelectionStart;         int selLen = rtf.SelectionLength;          rtf.SelectionStart = 0;         rtf.SelectionLength = rtf.TextLength;         rtf.SelectionFont = Font;         bool first = true;         foreach (Group g in m.Groups)         {             if (first) { first = false; continue; }             rtf.SelectionStart = g.Index;             rtf.SelectionLength = g.Length;             rtf.SelectionFont = dataFont;         }          rtf.SelectionStart = selSt;         rtf.SelectionLength = selLen;     }      private void MaskedEdit_FontChanged(object sender, EventArgs e)     {         dataFont = new Font(Font, FontStyle.Bold);     } } 
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 317k
  • Answers 317k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Answering my own question. I had to use Javascript in… May 13, 2026 at 11:46 pm
  • Editorial Team
    Editorial Team added an answer You could die into a new shell that sits at… May 13, 2026 at 11:46 pm
  • Editorial Team
    Editorial Team added an answer Try and give the absolute path to the ant executable,… May 13, 2026 at 11:46 pm

Related Questions

I've got a string that has curly quotes in it. I'd like to replace
I have a French site that I want to parse, but am running into
I want use html5's new tag to play a wav file (currently only supported
I ran into a problem. Wrote the following code snippet: teksti = teksti.Trim() teksti
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.