I need to add a variable pair list in a form (Name-Value). I decided to set it in a datagridview, and use simple binging to manage it (.NET 2):
public class EventParameter
{
private string name;
public string Name
{
get { return name; }
set { name = value; }
}
private string value;
public string Value
{
get { return this.value; }
set { this.value = value; }
}
}
///////////////////// USER CONTROL INITIALIZATION
private List<EventParameter> eventGridParams;
public GridEventSender()
{
InitializeComponent();
eventGridParams = new List<EventParameter>();
this.dataGridView1.AutoGenerateColumns = true;
this.dataGridView1.DataSource = eventGridParams;
}
///////////////////// ADD PARAMETER BUTTON
private void btnAddParam_Click(object sender, EventArgs e)
{
eventGridParams.Add(new EventParameter());
}
When I launch the application, I see that 2 columns, Name and Value are autogenerated, and the grid is empty.
But when I click on the Add parameter button, nothing happens... Where is the error?