Key Processing Question

G

Gene Jones

Hi all, I've been working on a little app some friends and I need to
help us enter a lot of XML data. There are a few places where html
code is entered in, and it's silly to keep typing <b>, </b> etc. My
plan was to set it up where you could just hit ctrl+b/ctrl+i (for
<i></i>) and it would toggle between the open and close tags, OR if
there is text selected, will return that text enclosed by the
appropriate tags.

It works. Sort of...

The problem is that the bold key works perfectly, exactly what I
wanted. Meanwhile, the italics key, which uses the EXACT SAME CODE as
the bold key, inserts a bunch of spaces/tabs or something, and erases
text in the box when it does it. I notice that in an empty textbox or
richtextbox, hitting Ctrl+I seems to do a long tab (about 8 spaces or
so).

Is this Ctrl+I something I'm not going to be able to override? I've
been googling for about an hour now and still haven't come up with a
solution for this. If anyone can help, I'd greatly appreciate it.
 
J

james.curran

Well, Ctrl-I is the standard keystroke for Tab. (As defined in the
original ASCII standard, circa 1960)

Where (into what?) are you entering the text, and how are you capturing
the Ctrl-I ?
 
H

homer jay

Well, Ctrl-I is the standard keystroke for Tab. (As defined in the
original ASCII standard, circa 1960)

Where (into what?) are you entering the text, and how are you capturing
the Ctrl-I ?

Into a textbox control on a windows form, and capturing it with
OnKeyUp. Is there some simple way I can cancel the default behavior of
this keystroke? I know it's possible because most word processors do
it...
 
G

Guest

hi. OnKeyUp takes a single parameter of type KeyEventArgs. have a look in the
documentation at KeyEventArgs.Handled and KeyEventArgs.SupressKeyPress.

for example if you do the following you can "swallow" and Ctrl+I key presses..

if (e.KeyCode == Keys.I && e.Control)
e.Handled = true;
 
G

Gene Jones

hi. OnKeyUp takes a single parameter of type KeyEventArgs. have a look in the
documentation at KeyEventArgs.Handled and KeyEventArgs.SupressKeyPress.

for example if you do the following you can "swallow" and Ctrl+I key presses..

if (e.KeyCode == Keys.I && e.Control)
e.Handled = true;

I'd been looking at the Handled thing, but I still can't get it to
work. Using your example there, would I put that before or after the
code I want executed when you hit Ctrl+I?

Thanks for the replies everybody, by the way.

Gene
 

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