Delete Key behavior

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

Guest

I've converted my VB6 app to VB.NET 2003. For some strange reason, the delete
key will not work in any of my textboxes in the application. The backspace
key works just fine. The delete key works in textboxes in VB6. Is there some
new event that I need to code for the delete key in VB.NET?
 
Hi Joemanc,

Are you processing text in a textbox using the KeyPress event? If so, not
that the delete key does not appear in this event, but you can trap it in
KeyUp/KeyDown.
 
Morten - I am not not using the KeyPress event. Am I now required to trap the
Delete keypress in .NET? Seems odd that I would have to trap the Delete
keypress keypress, but not the backspace key.

Oddly enough, I discovered in one of my application's smaller forms, the
delete button works. I double-checked the properties of the different
textboxes and the different forms and could not find any differences.
 
No, you don't have to detect the delete key for normal use of the textbox,
characters should be deleted using [Delete] or [Backspace], but unlike
[Backspace], which has a character \b, there is no character for [Delete].

Try trapping keys in a KeyDown event to see if the delet button is event
sent to the TextBox. It may be trapped by the form somehow.
 
Morton - I tried trapping keys using Keydown, and Delete was not detected. I
tried several other keys and they all worked.

Any thoughts on where I might be trapping the DELETE key? I haven't seen or
found anything obvious yet.

Seems like there are several new tools with .NET I can use to debug. I'm
fairly new to .NET, but I'll start taking a look at them.


Morten Wennevik said:
No, you don't have to detect the delete key for normal use of the textbox,
characters should be deleted using [Delete] or [Backspace], but unlike
[Backspace], which has a character \b, there is no character for [Delete].

Try trapping keys in a KeyDown event to see if the delet button is event
sent to the TextBox. It may be trapped by the form somehow.


Morten - I am not not using the KeyPress event. Am I now required to
trap the
Delete keypress in .NET? Seems odd that I would have to trap the Delete
keypress keypress, but not the backspace key.

Oddly enough, I discovered in one of my application's smaller forms, the
delete button works. I double-checked the properties of the different
textboxes and the different forms and could not find any differences.
 
The only way I can think of is by using KeyPreview = true for your parent
form, and using the formm's KeyDown event, trapping the Delete Key, like
this

protected override void OnKeyDown(KeyEventArgs e)
{
if (e.KeyCode == Keys.Delete)
e.Handled = true;
}

Another way is by overriding PreProcessMessage or WndProc, but I guess you
would know if you had used those.

If this problem exists solely in this single project I'm afraid I can't
help you without seeing your code.



Morton - I tried trapping keys using Keydown, and Delete was not
detected. I
tried several other keys and they all worked.

Any thoughts on where I might be trapping the DELETE key? I haven't seen
or
found anything obvious yet.

Seems like there are several new tools with .NET I can use to debug. I'm
fairly new to .NET, but I'll start taking a look at them.


Morten Wennevik said:
No, you don't have to detect the delete key for normal use of the
textbox,
characters should be deleted using [Delete] or [Backspace], but unlike
[Backspace], which has a character \b, there is no character for
[Delete].

Try trapping keys in a KeyDown event to see if the delet button is event
sent to the TextBox. It may be trapped by the form somehow.


Morten - I am not not using the KeyPress event. Am I now required to
trap the
Delete keypress in .NET? Seems odd that I would have to trap the Delete
keypress keypress, but not the backspace key.

Oddly enough, I discovered in one of my application's smaller forms, the
delete button works. I double-checked the properties of the different
textboxes and the different forms and could not find any differences.

:

Hi Joemanc,

Are you processing text in a textbox using the KeyPress event? If so,
not
that the delete key does not appear in this event, but you can trap it
in
KeyUp/KeyDown.



On Mon, 21 Aug 2006 20:43:01 +0200, Joemanc
<[email protected]>
wrote:

I've converted my VB6 app to VB.NET 2003. For some strange reason, the
delete
key will not work in any of my textboxes in the application. The
backspace
key works just fine. The delete key works in textboxes in VB6. Is
there
some
new event that I need to code for the delete key in VB.NET?
 
Morten,
I added PreProcessMessage code to override, and that seemed to do the trick.
Not sure why the Delete keypress was getting eaten up. Thanks for your help!

Morten Wennevik said:
The only way I can think of is by using KeyPreview = true for your parent
form, and using the formm's KeyDown event, trapping the Delete Key, like
this

protected override void OnKeyDown(KeyEventArgs e)
{
if (e.KeyCode == Keys.Delete)
e.Handled = true;
}

Another way is by overriding PreProcessMessage or WndProc, but I guess you
would know if you had used those.

If this problem exists solely in this single project I'm afraid I can't
help you without seeing your code.



Morton - I tried trapping keys using Keydown, and Delete was not
detected. I
tried several other keys and they all worked.

Any thoughts on where I might be trapping the DELETE key? I haven't seen
or
found anything obvious yet.

Seems like there are several new tools with .NET I can use to debug. I'm
fairly new to .NET, but I'll start taking a look at them.


Morten Wennevik said:
No, you don't have to detect the delete key for normal use of the
textbox,
characters should be deleted using [Delete] or [Backspace], but unlike
[Backspace], which has a character \b, there is no character for
[Delete].

Try trapping keys in a KeyDown event to see if the delet button is event
sent to the TextBox. It may be trapped by the form somehow.


On Tue, 22 Aug 2006 14:51:03 +0200, Joemanc
<[email protected]>
wrote:

Morten - I am not not using the KeyPress event. Am I now required to
trap the
Delete keypress in .NET? Seems odd that I would have to trap the
Delete
keypress keypress, but not the backspace key.

Oddly enough, I discovered in one of my application's smaller forms,
the
delete button works. I double-checked the properties of the different
textboxes and the different forms and could not find any differences.

:

Hi Joemanc,

Are you processing text in a textbox using the KeyPress event? If
so,
not
that the delete key does not appear in this event, but you can trap
it
in
KeyUp/KeyDown.



On Mon, 21 Aug 2006 20:43:01 +0200, Joemanc
<[email protected]>
wrote:

I've converted my VB6 app to VB.NET 2003. For some strange reason,
the
delete
key will not work in any of my textboxes in the application. The
backspace
key works just fine. The delete key works in textboxes in VB6. Is
there
some
new event that I need to code for the delete key in VB.NET?
 
Back
Top