Keys enumeration

  • Thread starter Thread starter C Glenn
  • Start date Start date
C

C Glenn

I'm writing some code in a KeyUp handler and can't find the Keys
enumeration member for the semicolon ';'. I found Keys.OemSemicolon,
but that doesn't get what I'm after. Anyone out there know how to trap it?
 
OemSemicolon works for me (using a UK keyboard with XP). Why not put a
breakpoint in your handler and check what e.KeyCode actually is?

Chris Jobson
 
OemSemicolon works for me (using a UK keyboard with XP). Why not put a
breakpoint in your handler and check what e.KeyCode actually is?

Chris Jobson
 
OK, Maybe I should tell everyone what I'm really trying to do.

This code is executing within the OnKeyUp handler, that much is true,
but I'm using IndexOfLast to locate specific characters within certain
strings, rather than testing the last key released.

SoFar.LastIndexOf((char)Keys.OemSemicolon)

always returns -1 even when there are numerous ';' within SoFar. My
routine works great with Keys.Space, but OemSemicolon bombs.

Any other thoughts on this?
 
C Glenn said:
OK, Maybe I should tell everyone what I'm really trying to do.

This code is executing within the OnKeyUp handler, that much is true,
but I'm using IndexOfLast to locate specific characters within certain
strings, rather than testing the last key released.

SoFar.LastIndexOf((char)Keys.OemSemicolon)

always returns -1 even when there are numerous ';' within SoFar. My
routine works great with Keys.Space, but OemSemicolon bombs.

Any other thoughts on this?

Yes - if you're trying to look through a *string* for a semi-colon,
then do exactly that:

SoFar.LastIndexOf(';');

The Keys enumeration is meant for processing keyboard input, not for
looking for characters in strings.
 
Thanks.


Yes - if you're trying to look through a *string* for a semi-colon,
then do exactly that:

SoFar.LastIndexOf(';');

The Keys enumeration is meant for processing keyboard input, not for
looking for characters in strings.
 

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