private void NumericPad_Click(object sender, System.EventArgs e) { foreach (Control controls in this.Controls) { if (controls.Name == strLostFocus) { if (Object.ReferenceEquals(controls.GetType(), typeof(CompletionComboBox))) { CompletionComboBox mycontrol = new CompletionComboBox(); Button button = (Button)sender; if (controls.CanFocus) { controls.Focus(); SendKeys.SendWait(button.Text); } } } } }
private void InitializeComponent() { this.FourButton = new System.Windows.Forms.Button(); this.CompletionComboBox = new keypad.CompletionComboBox(); this.SuspendLayout(); this.FourButton.Location = new System.Drawing.Point(100, 150); this.FourButton.Name = "FourButton"; this.FourButton.Size = new System.Drawing.Size(50, 45); this.FourButton.TabIndex = 29; this.FourButton.Text = "4"; this.FourButton.Click += new System.EventHandler(this.NumericPad_Click); this.CompletionComboBox.Location = new System.Drawing.Point(32, 88); this.CompletionComboBox.Name = "CompletionComboBox"; this.CompletionComboBox.Size = new System.Drawing.Size(200, 21); this.CompletionComboBox.TabIndex = 3; this.CompletionComboBox.LostFocus += new System.EventHandler(this.COMBOBOX_LostFocus); this.CompletionComboBox.Text = "<Press Keys or Buttons>"; this.CompletionComboBox.Items.AddRange(new object[] { "440 - Line 0", "441 - Line 1", "442 - Line 2", "443 - Line 3", "444 - Line 4 ", "445 - Line 5", "446 - Line 5"}); this.ClientSize = new System.Drawing.Size(292, 266); this.Controls.Add(this.FourButton); this.Controls.Add(this.CompletionComboBox); this.Name = "Form1"; this.Text = "Form1"; this.ResumeLayout(false); }