build and assign an array to a combo box

J

Jeff Williams

How di I dynamically build and 2 dimensional array and assign this array
to a combobox. 1 item will be the displayed details and the other is
the value I need returned.
 
C

C# Beginner

You can add any object to a listbox, even classes. For example:

class Product
{
private int ProductID;
private string ProductName;

public Product(int productid, string productname)
{
this.ProductID = productid;
this.ProductName = productname;
}
}

Product myProduct = new Product(5343, "Car");

ListBox.Items.Add(myProduct);

Product selectedProduct = ListBox.SelectedItem() as Product;

hope you find it useful
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top