[dba-VB] ControlChars in C#

Gustav Brock Gustav at cactus.dk
Tue Mar 25 09:55:52 CDT 2008

Hi all

I can't believe this:


In Visual Basic you have a nice class ControlChars where you, for example, ControlChars.Back for the BackSpace character.
In C# you have to write ugly (char)8 or '\b' in stone age C++ style.

So I have to write all this code to avoid the beep after pressing Enter in the small navigator position field of the record navigation toolbar while still be able to edit the record number with both the Delete and the BackSpace keys:

        private void bindingNavigatorPositionItem_KeyPress(object sender, KeyPressEventArgs e)
            char c = e.KeyChar;
            if (Char.IsControl(c))
                if (c != (char)8) 
                    e.Handled = true;

What do you do? Live with the beep or run your own homebuilt ControlChars?


More information about the dba-VB mailing list