usercontrol
Posted: 2017年7月24日(月) 11:01
c#で、usercontrolのkeydownイベントをformで行いたいです。
方法を教えてください
方法を教えてください
using System;
using System.Windows.Forms;
using System.Drawing;
public class Program
{
[STAThread]
static void Main()
{
Form f;
TextBox usercontrol;
f = new Form();
usercontrol = new TextBox();
f.Text = "Form";
usercontrol.Text = "ABC";
f.Size = new Size(300, 200);
f.Location = new Point(200, 300);
usercontrol.Location = new Point(30, 20);
f.Controls.Add(usercontrol);
// [単一行ラムダ式]
usercontrol.KeyDown += (sender, e) => usercontrol.Text = "Key Down";
usercontrol.KeyUp += (sender, e) => usercontrol.Text = "Key Up";
Application.Run(f);
}
}