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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T14:45:57+00:00 2026-06-07T14:45:57+00:00

I want a textbox that it is possible to add text blocks to it.

  • 0

I want a textbox that it is possible to add “text blocks” to it. The definition of a “text block” is:

  • Deleting a char in the textbox that is part of a block causing to the whole block to be deleted.
  • Setting the carot position in the textbox in a location that is part of a block causing to the whole block to be selected.
  • Any attempt of the user to write a char in a middle of a block will fails followed by an appropriate message box.

I have a DataGridView with a CellClick event attached to it. I want that when the CellClick event is occurs, the content of the cell will be placed in a textbox and will be considered as a text block. The location of the added block will be in the carot position of the textbox or at the end of the textbox if the textbox is not focused and thus the carot is not blinking.

I also want that the textbox could function as a normal textbox, meaning that the user can add or delete any chars/text he want excepts the text blocks that they must be added/deleted completely as defined above.

Maybe I need to use some other GUI controls except textbox to accomplish this mission, I don’t know.

I thought about some solutions but I don’t know which is the best (maybe none of them):
(remark: each of the following solutions assumes that there is an KeyPress event attached)

  1. Adding hidden characters (if possible) before and after each block to mark it.
  2. Creating a list of objects which represents all the text blocks, each object containing two fiels: startIndex, endIndex. Not so good because adding or deleting chars from the textbox requires to update all the indexes of the blocks located after the added/deleted chars by +1 or -1 for each char.
  3. Creating a list of objects which represents all the text in the textbox, each object containing two fields: text, flag. Each time a char is added manually or a word is added by the event, an object is added to the list and the object’s text field is set to the added chars, and the object’s flag filed is set to true if the chars are a word added by the event, or false otherwise.
  4. Splitting the textbox to 2 parts and creating a small textbox between them for each text block added by the event, and treating the small textbox diffetently. When the text in the small textbox is deleted the whole textbox control is deleted and the splited textbox is united. Doesn’t sounds me so good.

What is the best way to implement this?

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-07T14:46:00+00:00Added an answer on June 7, 2026 at 2:46 pm

    I have never seen a control with this behavior. I’m not saying that someone hasn’t written one, just that it’s unlikely. This means that you’re going to have to build it.

    If you’ve never created a custom control, search the web for “creating custom winforms controls” or similar. You first need to understand the basic techniques.

    Then you’re going to want to know how to store the underlying text for editing. You can start by learning some of the techniques commonly used for standard text-editing controls. Pick one that you can modify for your custom scenario. Here are a few off the top of my head:

    Gap Buffer

    Rope

    Piece Chains

    Good luck!

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

Sidebar

Related Questions

I have a textbox in a form that I created. I want to add
I have my own TextBox2 class that derives from TextBox. I want to add
I have a check box, RequiredFieldValidator and textbox that have editmask extender I want
I want to set the tabIndex property for a row of textbox(s) that are
I want to retrieve the moth from a date(in textbox),then If that retrieved month
I want to change the background color of a textbox as an indicator that
I have an asp:TextBox and I want to validate that the number of characters
Hi I want to make my textbox's width longer. The view that is generated,
Name: <%= Html.TextBox(txtName, 20, new { @class = hello }) %> I want that
If I want to validate that a text box contains an integer greater than

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.