Hi,

I have a rich text box and i like to skip enter key on the rich text box. i.e; If user pressed enter key the rich text box cursor should not move to next line rather than it should do some action.

I have achived this to some what. When enter key pressed it do action what needs to be done. the issue is, it also putting enter in the RTB. Say pointer in 70 line and i pressed enter key pointer move to 71 line and do the action what i have given. it needs to be pointer in 70 line and do the action. How to achive this....

Thanks in advance.....

Recommended Answers

All 3 Replies

Handle KeyDown event.

private void richTextBox1_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.KeyCode == Keys.Enter)
            {
                MessageBox.Show("Do some action here...");
                e.Handled = true;
            }

        }

it's worked...Thanks...Adatapost....

Glad you got it helpful. Please mark this thread as "Solved" :)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.