简体   繁体   中英

Combo Box Binding Issue

I have had an issue with a C# Windows Forms program recently. I have a Dictionary that I am binding to combobox.

private Dictionary<String, List<TaskDueDate>> m_IndividualSheetDetails = new Dictionary<string, List<TaskDueDate>>();
m_CboxPerson.DisplayMember = "Value";
m_CboxPerson.ValueMember = "Key";

The ValueMember is the key which is a string value corresponding to a person's name. The DisplayMember is a List of objects. When testing in visual studio everything works as suspected and the combox box populates with a list of names. This is what the combo box should look like.

在此处输入图片说明

While this is what the combobox actually looks like once installed and run on the computer.

在此处输入图片说明

Apparently you need ten rep to post images so all I have is the links. I am using clickonce deployment to deploy and install the application on other's machines. I am unsure why this is happening only on installation of the application. It runs fine and as it should in visual studio. Any advice would be greatly appreciated. Thanks

听起来您的ValueMember和DisplayMember与您想要的完全相反。DisplayMemeber用于显示,因此应为“键”,而ValueMemeber应为“值”

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM