Wrox Programmer Forums
Go Back   Wrox Programmer Forums > C# and C > C# 1.0 > C#
|
C# Programming questions specific to the Microsoft C# language. See also the forum Beginning Visual C# to discuss that specific Wrox book and code.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the C# section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old November 27th, 2007, 01:15 AM
Friend of Wrox
 
Join Date: Sep 2007
Posts: 169
Thanks: 7
Thanked 2 Times in 2 Posts
Default Disable Keys from the keyboard.

Hi

I have a list box list but right now a user can use the up arrow key, down arrow key and even the right and left arrow key(don't understand why a person can use the the right and left key since it is a single column list).

Anyways I want to disable their use of the right and left arrow key but I am unsure how to do this.

I also have another program if a user clicks on the down arrow and up arrow at the same time it will basically crash my program because it seems not to know which way to go.

How can I make it so it just takes the first one clicks or just disregards the click if both of them where hit at the exact same time.

Thanks

 
Old November 27th, 2007, 04:25 AM
Registered User
 
Join Date: Nov 2007
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
Default

You can inherit from listbox,then override the OnKeyDown event,like below:
protected override void OnKeyDown(KeyEventArgs e)
        {
            e.SuppressKeyPress = true;
            switch (e.KeyData)
            {
                case Keys.D0:
                case Keys.OemPeriod:
                case Keys.Decimal:
                    if (this.InputType == NordaBaseInputType.Float)
                        e.SuppressKeyPress = false;
                    break;
                default:
                    break;
            }
            base.OnKeyDown(e);
        }
this is a script of my program

-------------------------
yeah,I like cookie
www.recipeshow.org
 
Old December 6th, 2007, 02:39 PM
Authorized User
 
Join Date: Dec 2007
Posts: 25
Thanks: 0
Thanked 0 Times in 0 Posts
Default

How can you receive two key strokes at a time ? Os allows only one key stroke input per CPU Cycle.

dev(1);
 
Old December 6th, 2007, 07:34 PM
Friend of Wrox
 
Join Date: Sep 2007
Posts: 169
Thanks: 7
Thanked 2 Times in 2 Posts
Default

Well thats what I think the problem is but the debugger showed it as 2 separate calls so I don't know why it freezes then.






Similar Threads
Thread Thread Starter Forum Replies Last Post
How do I disable arrow keys sanderson Beginning VB 6 3 July 2nd, 2008 02:13 PM
How to disable ALT+ENTER keyboard shortcut q2q2 BOOK: Access 2003 VBA Programmer's Reference 0 November 8th, 2006 05:05 PM
Disable the special keys anukagni Access 1 July 16th, 2006 02:00 AM
When to define primary keys and foregin keys? method SQL Server 2000 1 August 26th, 2005 09:14 AM
Disable Keyboard shiju VS.NET 2002/2003 0 August 22nd, 2003 10:29 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.