gpt4 book ai didi

vb.net - 下拉列表应仅显示显示成员

转载 作者:行者123 更新时间:2023-12-02 07:12:50 25 4
gpt4 key购买 nike

我已将集合绑定(bind)到 ultracombo,并指定了值成员显示成员。集合有很多列,现在我必须在显示中仅显示一列,并将一列分配给值成员。现在我看到集合中的所有都显示​​为多列

//代码

 cboUltra.ValueMember = "LookupValue"
cboUltra.DisplayMember = "LookupValueDescription"
cboUltra.DataSource = LoadLookupDetails(Field.LookUpCode)
UltraGridRow.Cells("FieldValue").ValueList = cboUltra

我怎样才能实现这一目标?

最佳答案

在 C# 中,您可以尝试以下操作:--> 添加“ultraCombo1”作为您的 super 组合...在表单加载时尝试以下代码:

    private void Form1_Load(object sender, EventArgs e)
{
// Fill data in ultracombo datasource
DataTable dtt = new DataTable();
dtt.Columns.Add("ID", typeof(int));
dtt.Columns.Add("Name", typeof(string));
dtt.Columns.Add("Age", typeof(int));
dtt.Columns.Add("Address", typeof(string));
dtt.Columns.Add("Sex", typeof(string));
dtt.Rows.Add(new object[] {1,"Name1",20,"Address 1","Male"});
dtt.Rows.Add(new object[] { 2, "Name2", 21, "Address 2", "Male" });
dtt.Rows.Add(new object[] { 3, "Name3", 22, "Address 3", "Female" });
dtt.Rows.Add(new object[] { 4, "Name4", 23, "Address 4", "Male" });
dtt.Rows.Add(new object[] { 5, "Name5", 24, "Address 5", "Female" });
ultraCombo1.DataSource = dtt;
ultraCombo1.DataBind();
//---------------------------------

// hide all but show "ID" and "Name" only

ultraCombo1.ValueMember = "ID";
ultraCombo1.DisplayMember = "Name";
for (int i = 0; i < ultraCombo1.Rows.Band.Columns.Count; i++)
{
ultraCombo1.Rows.Band.Columns[i].Hidden = true;
}
ultraCombo1.Rows.Band.Columns["ID"].Hidden = false;
ultraCombo1.Rows.Band.Columns["Name"].Hidden = false;

}

您的 ultracombo 将仅填充“ID”的值成员和“Name”的显示成员。

关于vb.net - 下拉列表应仅显示显示成员,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16854159/

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