gpt4 book ai didi

c# - WinForms - 绑定(bind) ListBoxControl

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

我正在尝试将 List 绑定(bind)到 ListBoxControl (Devexpress)。除 DisplayMember 属性外,一切都很好。我看到列表已绑定(bind)(我可以使用鼠标或键盘在 3 个列表位置中移动)。问题是控件中没有文本。

public partial class ExportXml : XtraForm
{
private List<Xml> _listXml;

public ExportXml()
{
InitializeComponent();
LoadWindows();
}

private void LoadWindows()
{
_listXml = new List<Xml>
{
new Xml{Id = 1, Name1="xml1", Name2="xml11"},
new Xml{Id = 2, Name1="xml1", Name2="xml22"},
new Xml{Id = 3, Name1="xml1", Name2="xml22"}
};
_listBoxControl.DataSource = _listXml;
_listBoxControl.DisplayMember = "Name1";
_listBoxControl.ValueMember = "Id";
}
}

public class Xml
{
public int Id;
public string Name1;
public string Name2;
}

print screen

最佳答案

要完成此任务,请将自定义类的公共(public)字段替换为相应的公共(public)属性。

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

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