RichTextBox and AcceptButton

J

Jeff Haumesser

I have a form with the AcceptButton property set to a command button. I
also have a RichTextBox on the same form. With the AcceptButton property
set, I cannot enter a carriage return in the RichTextBox. It instead
activates the command button that is specified in the AcceptButton property.

Does anyone else have this problem and if so, how can I have both and
AcceptButton property set and able to enter a Carriage Return in the RTB
control?

Thankyou
 
O

One Handed Man [ OHM# ]

Wrong newsgroup Jeff, this is VB.NET not C#

Regards - OHM


Jeff said:
I have a form with the AcceptButton property set to a command button.
I also have a RichTextBox on the same form. With the AcceptButton
property set, I cannot enter a carriage return in the RichTextBox.
It instead activates the command button that is specified in the
AcceptButton property.

Does anyone else have this problem and if so, how can I have both and
AcceptButton property set and able to enter a Carriage Return in the
RTB control?

Thankyou

Regards - OHM# OneHandedMan{at}BTInternet{dot}com
 
H

Herfried K. Wagner [MVP]

* "Jeff Haumesser said:
I have a form with the AcceptButton property set to a command button. I
also have a RichTextBox on the same form. With the AcceptButton property
set, I cannot enter a carriage return in the RichTextBox. It instead
activates the command button that is specified in the AcceptButton property.

Does anyone else have this problem and if so, how can I have both and
AcceptButton property set and able to enter a Carriage Return in the RTB
control?

In the RichTextBox's 'GotFocus' event, remove the accept button by
setting the form's 'AcceptButton' property to 'Nothing', in it's
'LostFocus' event handler you can re-assign the button to the property.
 
J

Jeff Haumesser

Yeah, that's what I ended up doing. I just thought there was a more
graceful way to solve it.

Thankyou all for your response.

p.s. I know nothing about C#
 
O

One Handed Man [ OHM# ]

The Moon is on conjunction with Venus's orbit and the clouds are across
Mars. I can think of no other reason for me to have said that so please
ignore me completely.

OHM


Armin said:

Regards - OHM# OneHandedMan{at}BTInternet{dot}com
 
O

One Handed Man [ OHM# ]

The Moon is on conjunction with Venus's orbit and the clouds are across
Mars. I can think of no other reason for me to have said that so please
ignore me completely.

OHM

Regards - OHM# OneHandedMan{at}BTInternet{dot}com
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top