4

Prevent RichTextBox from creating a new line when Enter is pressed

 2 years ago
source link: https://www.codesd.com/item/prevent-richtextbox-from-creating-a-new-line-when-enter-is-pressed.html
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

Prevent RichTextBox from creating a new line when Enter is pressed

advertisements

This question already has an answer here:

  • Custom RichTextBox Event Handle 1 answer

I want to run a method when the Enter key is pressed within a RichTextBox so I made this code.

private void richTextBox1_KeyDown(object sender, KeyEventArgs e)
{
    if (e.KeyCode == Keys.Enter)
        MessageBox.Show("Hello World");
}

But I don't want to make a new line when the Enter key is pressed. But I can't manage to make that work.


Use e.Handled = true; this doesn't allow Enter Key to make a new line:

if (e.KeyCode == Keys.Enter)
{
     MessageBox.Show("Hello World");
     e.Handled = true;
}

Related Articles

How can I prevent sublime from inserting a new line when I stick?

Why is sublime inserting a line when I paste something? This has always sort of bothered me and I would like to prevent this.For some reason the OS X version of Sublime does not have key bindings for the Home and End keys, possibly because some Apple

Creating a new line when writing to a text file with javascript or jquery

I have a function where I grab the .text() of a table in javascript. I strip out the HTML tags, but when I then write it to a text file, I am left with one large blob. function removeHtml(html) { var result; var rm = new RegExp("</td>", &q

Xpages - How to prevent users from creating a new document if there is already one

I'm working on a Notes database. I want to prevent a user from creating a new document if there already exists a completed document from/by the user. In Notes classic form, I have incorporated that check in the QueryOpen event (see code below) and it

How to create a new line when the text overflows the line?

When creating a new img holder: <img src="holder.js/200x75/industrial/text:this text is too long for only one row"> There is no enough space in one row to hold the text, and I can't get a hold of how to do break for new line. Does anyone h

How to prevent others from creating a new instance of your class on the stack?

Suppose you write a class A, with constructor being private (to prevent others to create it on stack) then one day another developer add a new ctor, say A(int), and want to use inside main(): A a(1) to create it on stack. How do you prevent that? my

Select the following line when Enter is pressed when editing an NSTextField inside a NSTableView

I set some NSTextFields inside my view-based NSTableView to be editable, and to send an action on "end editing" (so when Enter or Tab is pressed, or when the focus is lost). The behavior when hitting Tab is perfect: the cell on the right of the

How do you prevent others from creating a new instance of a class on the job?

Possible Duplicate: How do I prevent a class from being allocated via the 'new' operator? (I'd like to ensure my RAII class is always allocated on the stack.) Suppose I define a class in the library class Base {}; and I publish the class to the users

SQL creates a new line when I execute an update command

I have this script (below), which is meant to update a value for a specific row in a table. I am searching by ID, which is set as an auto-incrementing, primary key integer. When I run this script, the row is not updated- instead, a completely new row

Prevents Flexbox from displaying a new line

I have a parent and two main children. The first child has two elements with fixed width and height. The second child has some text and when I resize text is shown or hidden in response to page size. But when I resize at a certain point the two eleme

Prevent python from printing a new line

I have this code in Python inputted = input("Enter in something: ") print("Input is {0}, including the return".format(inputted)) that outputs Enter in something: something Input is something , including the return I am not sure what is

AngularJS - Creating a new line when using ng-repeat

I'm using a simple ng-repeat to generate a list of countries and their corresponding data. Within each list is a hidden row that can be expanded and collapsed. I'm struggling to get this hidden row to appear at the bottom of each row from the ng-repe

How to prevent the enter key from creating a new row in a multi-line text box?

I want to prevent the Enter key from making a new line inside the multiple line text box using the KeyDown event. Despite clearing the textBox using textBox.Text = "" or textBox.Clear(), it behaves like this: http://i.imgur.com/3sknAbO.png priva

Unable to create a new line in my string

Just started day 2 of migrating from Java to Ruby. My code is quite trivial, I want to print a 9x9 grid but when I go through my nested for loop I can't create a new line termination. Please let me know what I'm missing here, thanks! table = ""

How to prevent users from creating repetitive identifiers?

In my web application I have a simple employee form. Each employee has a unique id associated with it. When a new employee is added to the system, a unique id is assigned to him. This id can be assigned manually or can be generated by the system. We

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK