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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T16:32:42+00:00 2026-05-23T16:32:42+00:00

I need to create a usercontrol Console. I was faced with such problems: If

  • 0

I need to create a usercontrol “Console”.

I was faced with such problems:

  • If I use a TextBox, how do I prevent removal of an already recruited command?

  • If I use a ListBox/ListView, how do I select all the text?

Please tell me what to do from the Console.

The console should be able to complete the command (by pressing Tab), allow selection of text, and prevent the entry of already established commands.

  • 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-23T16:32:42+00:00Added an answer on May 23, 2026 at 4:32 pm

    You could consider deriving from the RichTextBox control, as Tigran suggested.

    Depending on what you want the user to be able to do, you will have to put some logic in there that restricts what they can and cannot select. (For example, if you don’t want them selecting previous commands). You can obtain the text that they’ve selected via the SelectedText property. And then put in your custom logic, for example, Ctrl+C will copy the text into a variable.

    You may consider having a MaximumSize property so that old commands will be erased after the console becomes so large.

    Winforms already has a type of Autocomplete that you could use, or simply keep a list of keywords and when the user presses TAB, fill in the first word in your list that starts with what they’ve already typed.

    To obtain the command itself, and not any of the previous text that was entered, you will probably want to take everything from the LAST newline to the end.
    The code may look something like this:

    String allText = this.richTextBox1.Text;           // All the text from the rich text box
    Int32 lastIndex = allText.LastIndexOf("\n");       // Find the position of the last newline
    String command = allText.Substring(lastIndex + 1); // Substring starting at the character after the last newline
    

    And of course when the user presses RETURN, the command will be sent to your code and executed.

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

Sidebar

Related Questions

Maybe the obvious answer is that I need to use a UserControl but I'd
I need to create a user control, that will be used in an application
We need to dynamically create (i.e. during runtime, via code-behind) UserControls and position them
I need create custom dialog and put JPanel into it. Is it possible?
i need create an email list sending to many emails. what is best solution
Need to create a custom DNS name server using C which will check against
I need to create a historical timeline starting from 1600's to the present day.
I need to create an XML schema that looks something like this: <xs:element name=wrapperElement>
I need to create a linked server to a DB2 database on a mainframe.
I need to create an ASP page (classic, not ASP.NET) which runs remote shell

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.