简体   繁体   English

C#在组合框中传递值成员,然后显示其相应的显示成员

[英]C# Pass the Value Member in a combobox then display its corresponding Display Member

I would just like to ask for help in C#, I am currently learning to code in C#.. 我想在C#中寻求帮助,我目前正在学习在C#中进行编码。

I have values in my Mysql Database, for example position, it's data is codes, ( 104, 105, 111,) etc. its code have each corresponding position. 我在Mysql数据库中有值,例如位置,它的数据是代码(104、105、111等),其代码具有每个对应的位置。 (104-Manager, 105-Senior Manager, 111- Supervisor), on my combobox. (104位经理,105位高级经理,111位主管),在我的组合框中。

I am currently on the issue that I need to update the position of an existing employee.. 我目前遇到的问题是我需要更新现有员工的职位。

I need to get the value of the employee that i want to change the position then pass it on the combobox.. displaying its Description/position(manager,supervisor,Sr. Manager) using the valuemember/pcode.. Thanks in advance. 我需要获取要更改职位的员工的价值,然后将其传递到组合框上。使用valuemember / pcode显示其描述/职位(经理,主管,高级经理)。

And also the combobox that i have created is bound to a datasource.. 我创建的组合框也绑定到数据源。

Click here 点击这里

public class ComboboxItem
{
    public string Text { get; set; }
    public object Value { get; set; }

    public override string ToString()
    {
        return Text;
    }
}

private void Test()
{
    ComboboxItem item = new ComboboxItem();
    item.Text = "Supervisor";
    item.Value = 111;

    comboBox1.Items.Add(item);
}

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

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