Ich habe eine Schaltfläche zu meinem Formular hinzugefügt und Fehler cs1061.Ich habe bereits Methode geschützt. Fehler CS1061 'Cos' enthält keine Definition für 'button1_Click' und keine Erweiterungsmethode 'button1_Click' konnte ein erstes Argument vom Typ 'Cos' finden (fehlt eine using-Direktive oder eine Assembly-Referenz?) Projectbaze D: \ Anul3 \ baze de date \ projectbaze \ projectbaze \ Cos.Designer.cs 64 AktiveCompiler Fehler cs1061 Visual Studio
namespace projectbaze
{
public partial class ptlaptopuri : UserControl
{
public ptlaptopuri()
{
InitializeComponent();
}
protected void button1_Click(object sender, EventArgs e)
{
var context = new DataClasses2DataContext();
var alex = from emp in context.Produses
where (emp.Nume == "Asus" && emp.Categorie_id == 1)
select emp;
foreach (var a in alex)
{
Cos fm2 = new Cos();
fm2.AddGridViewRows(a.Nume.ToString(),a.Pret.ToString(),"1");
}
}
und
namespace projectbaze
{
public partial class Cos : Form
{
public Cos()
{
InitializeComponent();
}
public void AddGridViewRows(string Nume, string Pret, string Cantitate)
{
// Add rows to grid view.
dataGridView1.Rows.Add(Nume, Pret, Cantitate);
// Refresh the grid
dataGridView1.Update();
}
}
}
Die Fehlermeldung ist ziemlich klar: Sie haben offensichtlich versucht, einen Ereignishandler mit dem Namen 'button1_Click' zu einem Steuerelement in' Cos' via Designer hinzuzufügen. Aber "Cos" enthält keine solche Methode, Sie haben diese Methode in 'Ptlatopuri' deklariert, nicht in' Cos'. –