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

  • SEARCH
  • Home
  • 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 7547951
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T09:35:16+00:00 2026-05-30T09:35:16+00:00

Ok, what I have going on is a textbox that has been filled with

  • 0

Ok, what I have going on is a textbox that has been filled with some text depending on what was selected from a listbox.

say the textbox looks like this:

blah blah ??? as?f

what I need to figure out how to do is whenever the user clicks in the textbox and deletes a “?” character, I would like to replace that character with an * and then whenever they try to delete the * it will be replaced by a “?” , so that the end result will look something like

blah blah **? as*f

if they deleted all but one “?”.

No matter how long I have searched online I cannot seem to find anything similar.. the closest thing I have found is this question – Determine when and which character is added or deleted in a Text Box

But that doesnt really help for what I am trying to do.. if anyone has a good idea on where to start looking or even how to do it I would be very greatfull!

thanks in advance!

EDIT: Yes, this is for a Windows Form application, sorry i forgot to specify that. O.o

  • 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-30T09:35:18+00:00Added an answer on May 30, 2026 at 9:35 am

    You can handle KeyDown event and bypass default handling. The event handler can look like the following:

    public void OnKeyDown(Object sender, KeyEventArgs e)
    {
       char[] text = textBox.Text.ToCharArray();
       int pos = textBox.SelectionStart;
    
       switch (e.KeyCode)
       {
           case Keys.Back: if (pos == 0) return; pos --; break;
           case Keys.Delete: if (pos == text.Length) return; break;
           default: return;
       }
    
       switch (text[pos])
       {
           case '?': text[pos] = '*'; break;
           case '*': text[pos] = '?'; break;
           default: return;
       }
       textBox.Text = new String(text);
       e.Handled = true;
    }
    

    You may also want to add checks for modifier keys, adjust cursor position, and implement custom behavior when text is selected, if needed.

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

Sidebar

Related Questions

I have a webpage (htm) that has a textbox (going to change it to
I have a text box that is going to be populated with a comma
I have a UserControl that contains a TextBox. The TextBox.Text property is data-bound and
I have a PHP page that has 1 textbox and when I press on
Hey everybody, this is what I have going on. I have two text files.
I have been going back and forth between C# and Java for the last
I have been going through the core jQuery code and had a few why
I have been going mad trying to figure out why my scripts weren't working,
Recently, I have been going through search trees and I encountered red-black trees, the
I've switched over to a Mac recently and, although things have been going quite

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.