gpt4 book ai didi

c# - 组合框未绑定(bind)

转载 作者:太空宇宙 更新时间:2023-11-03 21:40:34 24 4
gpt4 key购买 nike

我正在尝试通过数据集列绑定(bind)组合框。

我有以下数据集:

enter image description here

我想通过 LocationName 列绑定(bind)组合框。

我正在为此使用以下代码:

cmbLocation.DataBindings.Add(New Binding("Text", dsLocations, "LocationName"))

但它抛出以下错误:

Cannot bind to the property or column LocationName on the DataSource. Parameter name: dataMember

请帮帮我。

最佳答案

尝试将 ComboBox 绑定(bind)到数据源:

cmbLocation.DisplayMember = "LocationName";
cmbLocation.ValueMember = "LocationName";
cmbLocation.DataSource = dsLocations;

它更容易,IMO 更具可读性。

关于c# - 组合框未绑定(bind),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19492049/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com