I wonder what I need to do in order to make the DataGridView behave as expected:
I do have a List<ioChannel> (named myList ) of objects of this type:
public class ioChannel
{
public string Name { get; set; }
public int Id { get; set; }
}
I tried to bind the DataGridView to this list:
bs = new BindingSource { DataSource = myList };
dgvChannels.DataSource = bs;
Now I created a button that adds elements to myList :
private void btAddChannel_Click(object sender, EventArgs e)
{
myList.Add(new ioChannel() { Id = myList.Count, Name = "My Channel" });
}
When I press the button, my List gets populated with new ioChannel's, but the dgvChannels does not add any rows. What do I need to do in order to make this happen?
BTW: When myList gets populated with some ioChannel´s before assigning the BindingSource as DataSource, the get shown properly in the grid.
Aucun commentaire:
Enregistrer un commentaire