
April 1st, 2012, 10:31 AM
|
|
Registered User
|
|
Join Date: Jul 2010
Posts: 13
Time spent in forums: 3 h 56 m 31 sec
Reputation Power: 0
|
|
|
Combobox changing its index by itself
hi,
i have ComboBox in which I have names of employees.
I created ComboBox_SelectedIndexChanged so when I pick something from ComboBox, I take employee and do something [write somethin into TextBox]
Works fine, but I have problem when I have employees with same name: when I click to TextBox or some button, SelectedIndex is changed to index of employee with same name, but smaller index [i mean the one that is "upper" in ComboBox items]!
Any idea why? Can I make this behaviour stop?
For Combobox I have this class, because I need to show and receive different stuff:
Code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Diploma
{
//own class for combobox to show and use different item
class ComboBoxItem
{
private string name; // sth to show, eg employee name and surname
private string value; //eg: employee_id- make sure unique
public string Value
{
get { return this.value; }
set { this.value = value; }
}
public string Name
{
get { return name; }
set { name = value; }
}
public ComboBoxItem(string nName, string nValue)
{
this.name = nName;
this.value = nValue;
}
public override string ToString()
{
return this.name;
}
}
}
I have visual studio 2010, project is in C#
|