コード例 #1
0
        /// <summary>
        /// Converts key events to text characters, and adds them to the text
        /// label. If backspace key is pressed, it deleted the last character
        /// from the label.
        /// </summary>
        /// <param name="args">Key event arguments.</param>
        protected override void OnKeyDown(KeyEventArgs args)
        {
            base.OnKeyDown(args);

            if (args.Key == Keys.Back)
            {
                if (this.label.Text.Length > 0)
                {
                    Text = this.label.Text.Substring(0, this.label.Text.Length - 1);
                }
            }
            else if (!args.Alt && !args.Control)
            {
                Text += GUIManager.KeyToString(args);
            }
        }