Reputation: 233
I have a winform that has several modules that are created dynamically based on information in a database. each of these modules has an edit button. I want to be able to pass in an object through to the click handler and then to the new form yet I cannot figure out how. Any help would be awsome here is what i have:
PingServer temp = manager.servers.ElementAt(i).Value;
EditButton.Click += new EventHandler(openEditor(temp));
private void openEditor(PingServer server)
{
EditConnectionForm editConnection = new EditConnectionForm(server);
editConnection.ShowDialog();
}
Upvotes: 0
Views: 132
Reputation: 203827
Close over the variable using a lambda:
EditButton.Click += (sender, args) => openEditor(temp);
Upvotes: 2