简体   繁体   English

ComboBox在WCF回调上未绑定

[英]ComboBox not binding on WCF callback

I'm creating a sample chat application. 我正在创建一个示例聊天应用程序。

On Form load, WCF service is called. 在窗体加载时,将调用WCF服务。 -- here user's callback is registered at wcf service, added to a UserList -这里的用户回调是在wcf服务处注册的,已添加到UserList

Other users are notified about the current users by sending the UserList to them using their callback. 通过使用回调向其他用户发送用户列表,可以通知其他用户当前用户。 Callback cals UpdateClientList method at client side. 回调在客户端UpdateClientList方法。

WCF service is able to call the Client's method " UpdateClientList(List<PropUser> listuser) ". WCF服务能够调用客户端的方法“ UpdateClientList(List<PropUser> listuser) ”。

But, inside the method even following hard-coded lines are not able to bind them: 但是,即使在方法内部,即使遵循以下硬编码的行也无法将其绑定:

List<PropUser> listuser = new List<PropUser>();
            listuser.Add(new PropUser { Id = "1", Name = "Ram" });
            listuser.Add(new PropUser { Id = "2", Name = "Shyam" });
            listuser.Add(new PropUser { Id = "3", Name = "Ramam" });

            comboBox1.DisplayMember = "Name";
            comboBox1.ValueMember = "Id";
            comboBox1.DataSource = listuser;

even comboBox1.Enabled= false; 甚至comboBox1.Enabled= false; is not working 不管用

MessageBox.Show("Hi"); is working. 正在工作。

Note: it is windows application not web 注意:它是Windows应用程序而不是Web
Please suggest: 请提出以下建议:

When you added reset the datasource do you call the update method on the Combobox ? 添加重置数据源后,您是否在组合框上调用了update方法?

If you used a binding source as the intermediary - you could call ResetBindings(false); 如果您使用绑定源作为中介,则可以调用ResetBindings(false);。 That would do the trick for you. 那将为您解决问题。

However in your scenario - you need to refresh your combobox by calling the Update() method on the box, combobox1.Update(); 但是,在您的方案中-您需要通过调用框上的Update()方法combobox1.Update()来刷新组合框。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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