Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Checkbox question
Message
De
14/01/2010 16:37:11
 
Information générale
Forum:
ASP.NET
Catégorie:
Formulaires
Versions des environnements
Environment:
C# 3.0
OS:
Windows Server 2003
Network:
Windows 2003 Server
Database:
MS SQL Server
Application:
Desktop
Divers
Thread ID:
01442521
Message ID:
01444058
Vues:
70
This message has been marked as the solution to the initial question of the thread.
Linda,

You'll have to override the Form's ProcessCmdKey() method. If you haven't done this before, the code should look something like this:
protected override bool ProcessCmdKey(ref Message msg, Keys keyData)
{
	const int WM_KEYDOWN = 0x100;
	const int WM_SYSKEYDOWN = 0x104;

	if ((msg.Msg == WM_KEYDOWN) || (msg.Msg == WM_SYSKEYDOWN))
	{
            // "eat" any key that is not a space, as if it were never pressed
	    if (ActiveControl is CheckBox && keyData != Keys.Space)
		return true;
	}

	return base.ProcessCmdKey(ref msg, keyData);
}
~~Bonnie



>A user noted that when a checkbox control has focus and a letter for one of the hot keys is pressed (e.g., D for the delete button), the hot key fires without requiring Alt+D to be pressed.
>Now I realize that the user should not be pressing anything besides Enter or Space when on a checkbox control but . . .
>Does anyone have any suggestions other than 1) setting the tabstop property to false; 2) eliminating the hot keys; 3) training the users?
>Thanks.
Bonnie Berent DeWitt
NET/C# MVP since 2003

http://geek-goddess-bonnie.blogspot.com
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform