[dba-VB] ControlChars in C#

jwcolby jwcolby at colbyconsulting.com
Tue Mar 25 11:03:00 CDT 2008


Yea, it reminds me of the old days when you had an ascii chart taped to the
wall.  Back in the day I could tell you from memory the ascii code for the
space, cr, lf etc.  Numbers were easy, upper and lower case not so easy, and
I was always looking up the special characters. 

Of course REAL men don't need no steenkin ASCII chart either.  ;-)

John W. Colby
Colby Consulting
www.ColbyConsulting.com 
-----Original Message-----
From: dba-vb-bounces at databaseadvisors.com
[mailto:dba-vb-bounces at databaseadvisors.com] On Behalf Of Gustav Brock
Sent: Tuesday, March 25, 2008 11:49 AM
To: dba-vb at databaseadvisors.com
Subject: Re: [dba-VB] ControlChars in C#

Hi John

Don't hide. Even Mid(something) would be nicer than '\b' ...!

/gustav

>>> jwcolby at colbyconsulting.com 25-03-2008 16:03 >>>
Oh I know.  Waving hand wildly in the air.

Use Mid().

<grin> 

I just couldn't resist.

<ducks under table, giggling insanely>


John W. Colby
Colby Consulting
www.ColbyConsulting.com
-----Original Message-----
From: dba-vb-bounces at databaseadvisors.com
[mailto:dba-vb-bounces at databaseadvisors.com] On Behalf Of Gustav Brock
Sent: Tuesday, March 25, 2008 10:56 AM
To: dba-vb at databaseadvisors.com
Subject: [dba-VB] ControlChars in C#

Hi all

I can't believe this:

http://msdn2.microsoft.com/en-us/library/system.windows.forms.keypresseventa
rgs(VS.71).aspx

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?

/gustav



_______________________________________________
dba-VB mailing list
dba-VB at databaseadvisors.com
http://databaseadvisors.com/mailman/listinfo/dba-vb
http://www.databaseadvisors.com




More information about the dba-VB mailing list