TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Ray
NA
1
0
How do I set a combobox to a selected value when the combobox holds a class
Dec 24 2009 1:29 PM
I'm stuck on this one...I have a combobox that i've filled as shown below (code thinned out for simplicity):
[code]
// Load Material codes into combobox.
intID = somenumber; //ex: 123, 234
strItem = somestring; // ex: "white", "black"
Material item = new Material(intID, strItem);
cboMaterial.Items.Add(item);
// where Material is as shown below (code thinned out for simplicity):
private class Material
{
private int intMaterialID;
private string strMaterialCode;
public Material(int intID, string strItem)
{
intMaterialID = intID;
strMaterialCode = strItem;
}
public override string ToString()
{
return this.strMaterialCode;
}
}
[/code]
My question is that if later on in the code, if I know the value of "intID", how do I have the combobox display that selection?
While the following works, it's not what I need as I don't want to search for the strItem, but the intID.
[code]
cboMaterial.SelectedIndex = cboMaterial.FindStringExact("white")
[/code]
Reply
Answers (
1
)
How to use functions of external program in my C# project?
can anyone explains about Dictionary in details with examples