如何在c#visual studios 2013 express桌面修复此代码错误 [英] how to fix this code error in c# visual studios 2013 express desktop
问题描述
错误即将获得
错误1'SimpleWebBrowser.Form1.button3_Click(object,System.EventArgs)'必须声明一个正文,因为它未标记为abstract,extern或部分
我的代码
Error im getting
Error 1 'SimpleWebBrowser.Form1.button3_Click(object, System.EventArgs)' must declare a body because it is not marked abstract, extern, or partial
My Code
using System;
using System.Windows.Forms;
namespace SimpleWebBrowser
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
/// <summary>
/// This will close the application when the File->Exit menu item is selected
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void exitToolStripMenuItem_Click(object sender, EventArgs e)
{
this.Close();
}
/// <summary>
/// This will show a box with the author information when the about menu item is selected
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void aboutToolStripMenuItem_Click(object sender, EventArgs e)
{
MessageBox.Show("simple web browser nothing to it");
}
/// <summary>
/// On click of this button the web control will display the page requested in the text box (by url)
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void button1_Click(object sender, EventArgs e)
{
SearchteToPage();
}
private void SearchteToPage()
{
throw new NotImplementedException();
}
/// <summary>
/// This function will cause the browser to navigate to the URL in the textBox1 control
/// </summary>
private void aearchteToPage()
{
toolStripStatusLabel1.Text = "Navigation has started";
webBrowser1.Navigate(textBox1.Text);
}
/// <summary>
/// This function will start navigation by simulating a click on the navigate button when 'enter' is pressed when textbox1 is in focus
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void textBox1_KeyPress(object sender, KeyPressEventArgs e)
{
// if the keystroke was enter then do something
if (e.KeyChar == (char)ConsoleKey.Enter)
{
//NavigateToPage();
button1_Click(null, null);
}
}
/// <summary>
/// When the webpage is finished loading this function will re-enable the disabled controls and indicate success
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void webBrowser1_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e)
{
// Enable the controls that were disabled during navigation
button1.Enabled = true;
textBox1.Enabled = true;
// Indicate loading is complete
toolStripStatusLabel1.Text = "Navigation Complete";
toolStripProgressBar1.ProgressBar.Value = 100;
}
/// <summary>
/// This function will be called as the webpage loads multiple time to indicate the percentage complete
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void webBrowser1_ProgressChanged(object sender, WebBrowserProgressChangedEventArgs e)
{
// Don't bother computing percentage if either variable is zero since it will cause a divide by zero error
if (e.CurrentProgress > 0 && e.MaximumProgress > 0)
{
// Calculate percentage
int percentage = (int)(e.CurrentProgress * 100 / e.MaximumProgress);
// If the percentage is > 100 it means additional processing was done on the page so we want to ignore it
if (percentage <= 100)
{
toolStripProgressBar1.ProgressBar.Value = percentage;
}
}
else
{
// Set the percentage to zero if we can't compute it
toolStripProgressBar1.ProgressBar.Value = 0;
}
}
//start of button two code
//Right here
//right here
private void historyToolStripMenuItem_Click(object sender, EventArgs e)
{
}
private void textBox2_TextChanged(object sender, EventArgs e)
{
}
//ERROR LINE'S START HERE
private void button3_Click(object sender, EventArgs e);
private void button4_Click(object sender, EventArgs e)
{
Y_searchteToPage();
}
private void Y_searchteToPage()
{
throw new NotImplementedException();
}
private void Y_SearchteToPage()
{
throw new NotImplementedException();
}
/// <summary>
/// This function will cause the browser to navigate to the URL in the textBox1 control
/// </summary>
private void Y_aearchteToPage()
{
toolStripStatusLabel1.Text = "Navigation has started";
webBrowser1.Navigate(textBox2.Text);
}
}
}
推荐答案
错误实际上说明了一切:
The error actually says it all:
button3_Click(object, System.EventArgs)' must declare a body because it is not marked abstract, extern, or partial
您可能在UI中绘制了一个名为button3的按钮对象,并且您已经连接了一个click事件。
无论如何,您需要修改方法以便它有一个身体。因此,而不是
You probably have a button object named button3 drawn in your UI and you have wired a click event for it.
Anyways, you need to modify the method so that it has a body. So instead of
private void button3_Click(object sender, EventArgs e);
你应该有类似
的东西
you should have something like
private void button3_Click(object sender, EventArgs e) {
... do something over here...
}
如果实际上不需要这种方法,可以将其注释掉或完全删除。
If that method isn't actually needed, either comment it out or remove it completely.
这篇关于如何在c#visual studios 2013 express桌面修复此代码错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!