Visual Studio C#Windows窗体 [英] Visual Studio C# Windows Form

查看:94
本文介绍了Visual Studio C#Windows窗体的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当用户按下"T"时,我需要知道打开文本框的代码。键。因此,文本框仅在"T"时出现。按下"Enter"后,按下"Enter",文本框消失。

解决方案


试试这个:


< pre class ="prettyprint"> public Form1()
{
InitializeComponent();
this.KeyDown + = Form1_KeyDown;
this.KeyPreview = true; //设置为true
}

private void Form1_KeyDown(object sender,KeyEventArgs e)
{
if(e .KeyData == Keys.T)
{
textBox1.Visible = true;
}
if(e.KeyData == Keys.Enter)
{
textBox1.Visible = false;
}
}

问候,


Stanly


I need to know the code for opening a text box when the user presses the "T" key. So the text box only appears when "T" is pressed, and after pressing "Enter," the text box disappears.

解决方案

Hi,

Try this:

    public Form1()
    {
        InitializeComponent();
        this.KeyDown += Form1_KeyDown;
        this.KeyPreview = true;//set to true
    }

    private void Form1_KeyDown(object sender, KeyEventArgs e)
    {
        if (e.KeyData == Keys.T)
        {
            textBox1.Visible = true;
        }
        if (e.KeyData == Keys.Enter)
        {
            textBox1.Visible = false;
        }
    }

Regards,

Stanly


这篇关于Visual Studio C#Windows窗体的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆