usercontrol

フォーラム(掲示板)ルール
フォーラム(掲示板)ルールはこちら  ※コードを貼り付ける場合は [code][/code] で囲って下さい。詳しくはこちら
para

usercontrol

#1

投稿記事 by para » 8年前

c#で、usercontrolのkeydownイベントをformで行いたいです。 
方法を教えてください

Math

Re: usercontrol

#2

投稿記事 by Math » 8年前

Windows10のみ使用。(VisualStudio不要)

f.bat

コード:

C:\windows\Microsoft.NET\Framework64\v4.0.30319\csc.exe f1.cs
f1.exe
pause
f1.cs

コード:

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);
    }
}
f.bat をWクリックする。
画像
zキーを押す
画像
放す
画像

Math

Re: usercontrol

#3

投稿記事 by Math » 8年前

このhttps://msdn.microsoft.com/ja-jp/library/97855yckのことでしょうか。
状況と環境の詳しい説明をしてくださらないとわかりずらいですよね。(^^;

返信

“C言語何でも質問掲示板” へ戻る