0

I would just like to ask for help in C#, I am currently learning to code in 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. (104-Manager, 105-Senior Manager, 111- Supervisor), on my combobox.

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.

And also the combobox that i have created is bound to a datasource..

  • 1
    winforms?wpf?asp.net? – Sayse Sep 17 '14 at 08:58
  • I think all you need to do is bind the comboboxes value to your object's code – Sayse Sep 17 '14 at 09:37
  • thanks for the reply.. can you specify how sayse? thanks in advance for the help.. –  Sep 17 '14 at 09:43
  • I haven't got much time at the minute to formulate a full response at the minute sorry.. it sounds as though you are already providing some databinding on this source already though so you should be able to bind it to a second thing (can't remember if winforms allows this), If not just set the comboboxes value to the code when you change person – Sayse Sep 17 '14 at 09:44
  • my bad on that sayse, im using wpf, i was so excited on my reply earlier that i said winforms. LOL –  Sep 17 '14 at 09:48
  • wpf, has more support for binding so it should be possible to do a second binding. – Sayse Sep 17 '14 at 09:49
  • can you give me sample? sorry for being persistent, i have been searching for the answer for days now lol –  Sep 17 '14 at 09:51
  • Kimmm, sorry I don't have much time at the minute (just replying during compiling/waiting times) Its the same as the binding your already doing, just adding a second one – Sayse Sep 17 '14 at 09:52

1 Answers1

0

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);
}
Community
  • 1
  • 1
Ibki
  • 91
  • 4
  • it's already added on the combobox.. my issue is getting the specific positiion of the employee that i want to edit,based on the database data. –  Sep 17 '14 at 09:07
  • i used databound items.. now my question is.. for example, i want to pass pcode on the combobox, and it will display its description.. example.. i have Mark with pcode 104 on my database.. it should display as manager on the combobox.. –  Sep 17 '14 at 09:08