Text box questions revisited

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I posted some questions about text boxes and received a reply which partially
resolved the issues.

1. I want to construct a text box (or rich text box) where if you type a
space a dot character appears in the box. (like MS Word when the formatting
characters are displayed). Following advice from Larry Serflaten I created a
sub to check for Key Down events and inserted the following:

If e.KeyCode = 32 Then
e.Handled = True
RichTextBox1.SelectedText = Chr(183)
End If

This puts the dot in the text box when you hit the spacebar, but it also
puts a space character after the dot. Is there some keyboard buffer which
needs to be cleared as well? I thought the e.Handled statement was inserted
to take care of that but it clearly doesn't.

2. I want to be able to change the insert mode from Insert to Overwrite,
which I am able to do with a Rich Text box, (but not a normal text box). How
can I interrogate the Rich Text box to determine which mode it is in? Is
there a property somewhere which shows this? (This is so I can display on the
form an indication of what the currently active insert mode is.)

Grateful for any assistance.
 
simonc said:
1. I want to construct a text box (or rich text box) where if you type a
space a dot character appears in the box. (like MS Word when
the formatting characters are displayed). Following advice from
Larry Serflaten I created a sub to check for Key Down events
and inserted the following:

If e.KeyCode = 32 Then
e.Handled = True
RichTextBox1.SelectedText = Chr(183)
End If

Add a handler to the 'KeyPress' event instead of 'KeyDown'. In this event,
check 'KeyChar'.
 
Thank you for this. Do you have any advice on how to check if the RichTextBox
is in Insert or Overwrite mode?

Does the Insert key have a key character which could be checked?
 

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

Back
Top