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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T16:41:14+00:00 2026-05-20T16:41:14+00:00

After my textbox clears. The start position starts at second line instead of the

  • 0

After my textbox clears. The start position starts at second line instead of the first. (I’m not sure what’s the flashing | is called)

I’m making a chat server so there is a button to send the current text. And on keypress Enter it will activate button1 so as to send the current text.

TextChanged event is just purely for debugging purposes.

textChanged is called twice. Once on inBox.Text = string.Empty; This part is still fine. inBox.Text is null.

After exiting from button1_Click, TextChanged is called for the second time. But this time. the start position is on the second line instead of the first.
The length of inBox.Text is now 2.

Any idea what’s the problem? Thanks.

private void button1_Click(object sender, EventArgs e)
        {
            Global.Send("{Chat}{" + Global.userName + "}" + inBox.Text);
            inBox.Text = string.Empty;
        }

        private void inBox_KeyPress(object sender, KeyPressEventArgs e)
        {
            if (e.KeyChar == 13)
                button1.PerformClick();
        }

        void InBoxTextChanged(object sender, EventArgs e)
        {
            TextBox tb = (TextBox)sender;
            char[] c = tb.Text.ToCharArray();
            int len = c.Length;
        }
  • 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-20T16:41:15+00:00Added an answer on May 20, 2026 at 4:41 pm

    In the Inbox_Keypressed() method, set the KeyPressEventArgs.Handled property to true (also, you shouldn’t use 13 – Keys.Return is more readable):

    private void inBox_KeyPress(object sender, KeyPressEventArgs e)
    {
      if (e.KeyChar == 13)
      {
        button1.PerformClick();
        e.Handled = true;
      }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In the below code TextBox value is not getting cleared after clicking on Button.
I want to clear textbox after ajax posting. <div style=padding: 5px; background-color: Silver;> @using
I want to clear textbox after ajax posting. <div style=padding: 5px; background-color: Silver;> @using
How to cancel a keypress event in a textbox after pressing the return key.
How may i highlight the text when say, after a textbox is enabled after
How do I get to increment a textbox content after clicking on a button?
The below textbox is printing the value of the phone number after getting it
I have an extender control that raises a textbox's OnTextChanged event 500ms after the
After repeated searching I have not found an elegant solution to this issue: how
How to clear my TextBox after clicking SEND? using System; using System.Collections.Generic; using System.ComponentModel;

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.