我有一个功能private void change()
,我想运行时,我将按下一个按钮。我有Button schimbare = new Button();
,如果我按,运行该功能。我有一些问题button.Click事件
我尝试schimbare.Click += change();
,但不工作。什么是好的命令?
这是代码:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Drawing;
namespace Programarii
{
class InputBoxOptiuni
{
static TextBox textBox1 = new TextBox();
/// <summary>
/// Displays a dialog with a prompt and textbox where the user can enter information
/// </summary>
/// <param name="title">Dialog title</param>
/// <param name="promptText">Dialog prompt</param>
/// <param name="value">Sets the initial value and returns the result</param>
/// <returns>Dialog result</returns>
public static DialogResult Show(string title, string promptText, string informati, string mesaj, ref int ora, ref int minut30, ref int minut15, ref int douaore, ref int minut10, ref int minut5, ref int pornire2, ref int anuntare2, ref int cuparola, ref string parola, ref string email, ref int expirare, ref int cateminute, ref int vl, ref int culimba, string scurtaturi, string scurtaturi2, string format, ref int tipformat)
{
Button schimbare = new Button();
schimbare.Click += change;
}
private void change(object sender, EventArgs e)
{
}
}
}
对于这一切回答我,TNX。
我尝试:
private void change(object sender, EventArgs e) and schimbare.Click += change;
,但不起作用。我尝试与schimbare.Click += (s,e)=> { //your code };
和工作!
Tnx,我尝试了secound方法并且完美地工作。 Tnx再次! – AnDr3yy