【问题标题】:Populating a Combobox through WCF Service通过 WCF 服务填充组合框
【发布时间】:2017-05-18 11:38:02
【问题描述】:

我收到错误消息,“无法将类型 'System.Collections.IEnumberable' 隐式转换为 'string'。存在显式转换)”

我尝试过使用 Convert.ToString() 和 .ToString,但是当发生这种情况时,ComboBox 不会填充。 我可以直接使用 SQLConnection 填充,但我的主要目标是通过 WCF 服务实现。 我错过了什么?

C#:

{

    public MainWindow()
    {
        InitializeComponent();
        BindComboBox(cbxUsername);
    }

    public void BindComboBox(ComboBox Username)
    {
        ServiceReference1.Service1Client Client = new ServiceReference1.Service1Client();
        ServiceReference1.getUser GetUsername = new ServiceReference1.getUser();

        GetUsername.Username = cbxUsername.ItemsSource;

    }

    private void Button_Click(object sender, RoutedEventArgs e)
    {

    }
}

}

【问题讨论】:

    标签: c# wpf wcf combobox


    【解决方案1】:

    应该是其他方式,

     cbxUsername.ItemsSource = GetUsername.Username;
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-01-03
      • 2015-03-01
      • 1970-01-01
      • 2013-06-22
      相关资源
      最近更新 更多