Код: Выделить всё
Dictionary bs = new Dictionary() {"protocol", new BindingSource()};
this.protocolCombo.DataSource = bs["protocol"];
MessageBox.Show($"{this.protocolCombo.DisplayMember}"); //output: ""
this.protocolCombo.DisplayMember = "Name";
MessageBox.Show($"{this.protocolCombo.DisplayMember}"); //output: ""
bs["protocol"].DataSource = protocol_list;
Код: Выделить всё
Dictionary bs = new Dictionary() {"protocol", new BindingSource()};
this.protocolCombo.DataSource = bs["protocol"];
MessageBox.Show($"{this.protocolCombo.DisplayMember}"); //output: ""
bs["protocol"].DataSource = protocol_list;
this.protocolCombo.DisplayMember = "Name";
MessageBox.Show($"{this.protocolCombo.DisplayMember}"); //output: "Name"
Код: Выделить всё
public class Protocol
{
public string Name { get; set; }
public Protocol(string name)
{
Name = name;
}
}
Дополнительная информация: Этот проект написан под .Net6. 0
Подробнее здесь: https://stackoverflow.com/questions/789 ... displaymem