gpt4 book ai didi

c# - 为什么我无法访问 System.EventArgs 的 KeyCode 成员?

转载 作者:行者123 更新时间:2023-12-02 17:48:41 25 4
gpt4 key购买 nike

我做错了什么?这是我得到的错误代码:

'System.EventArgs' does not contain a definition for 'KeyCode' and no extension method 'KeyCode' accepting a first argument of type 'System.EventArgs' could be found (are you missing a using directive or an assembly reference?)

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace BroZer
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}

private void Reload_Click(object sender, EventArgs e)
{
webBrowser1.Refresh();
}

private void Go_Click(object sender, EventArgs e)
{
webBrowser1.Navigate(textBox1.Text);
}

private void Back_Click(object sender, EventArgs e)
{
webBrowser1.GoBack();
}

private void Forward_Click(object sender, EventArgs e)
{
webBrowser1.GoForward();
}

private void textBox1_KeyDown(object sender, EventArgs e)
{
if (e.KeyCode == Keys.Enter)
{
webBrowser1.Navigate("https://www.google.com/search?&ie=UTF-8&q=" + textBox1.Text);
}
}

private void webBrowser1_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e)
{

}

private void Save_Click(object sender, EventArgs e)
{
webBrowser1.ShowSaveAsDialog();
}

private void Print_Click(object sender, EventArgs e)
{
webBrowser1.ShowPrintPreviewDialog();
}
}
}

最佳答案

更新:我想通了。你所要做的就是改变

(object sender, EventArgs e)

(object sender, KeyEventArgs e)

关于c# - 为什么我无法访问 System.EventArgs 的 KeyCode 成员?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11321289/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com