954,500 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Objects from an array to a Combobox?

I am new to C# and stuck on this:

I have an array in my Dealership class that accepts user input for make, model, and year.

class Dealership
    {
        public static Car[] car = new Car[500];
        public static int carIndex = 0;
    }
public partial class FormAddCar : Form
{
 Dealership.car[Dealership.carIndex] = new Car(textBoxMake.Text, textBoxModel.Text, Convert.ToInt16(textBoxYear.Text), Convert.ToInt32(textBoxMileage.Text));
            Dealership.carIndex++;
}


I want a combo box to display these individually (make, model, year) and have looked up many examples with no success.
This is what I have so far...

public partial class FormSearchInventory : Form
{
private void comboBoxMake_SelectedIndexChanged(object sender, EventArgs e)
{
comboBoxMake.Items.AddRange(xxxxx);
}
}

HELP!

PennyPeso
Newbie Poster
2 posts since Dec 2011
Reputation Points: 10
Solved Threads: 0
 

Nevermind.. Solved.

for (int i = 0; i < Dealership.carIndex; i++)
                comboBox1.Items.Add(Dealership.car[i].Make);
PennyPeso
Newbie Poster
2 posts since Dec 2011
Reputation Points: 10
Solved Threads: 0
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You
View similar articles that have also been tagged: