【发布时间】:2018-10-26 00:18:12
【问题描述】:
我正在尝试使用 VS2017 和 C# 做一个表单,它将供个人使用。
我希望当我在其他应用程序(如 Word、Excel、记事本)中按“F2”键时,会自动显示之前在 TextBox 中确定到 Visual Studio 中的文本。
例如,如果表单有一个 TextBox1,其中包含“Hello”的文本,我希望在 Word 中按 F2 并显示文本“Hello”。
目前我有这个,但我认为是错误的
using System;
using System.Collections.Generic;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace WindowsFormsApp1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
}
private void Form1_KeyDown(object sender, KeyEventArgs e)
{
if (e.KeyData == Keys.F2)
{
SendKeys.Send(textBox1.Text);
}
}
}
}
如果你能帮我解决这个问题,我会很高兴的! :)
谢谢!
【问题讨论】:
标签: c# windows winforms visual-studio-2017