To start I enter some information into 4 textboxes which then the data is stored into a class.
I just add the class object into the list box to keep things simple and when i click on the object in the listbox I want it to show the original text that was entered into the text boxes. The objects all the have same name but they store different information based on what i enter and i want the original information to display into the textboxes when i click on each different object.
I'm thinking i need to use SelectedIndexChanged to do what i want but am not really sure how.
This is the class
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace hw
{
class Car
{
string make;
string model;
string year;
string price;
public void setMake(string _Make)
{
make = _Make;
}
public string getMake()
{
return make;
}
public void setModel(string _Model)
{
model = _Model;
}
public string getModel()
{
return model;
}
public void setYear(string _Year)
{
year = _Year;
}
public string getYear()
{
return year;
}
public void setPrice(string _Price)
{
price = _Price;
}
public string getPrice()
{
return price;
}
}
}
This is the form which contains the textboxes and listbox
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace hw
{
public partial class frmAdd : Form
{
public frmAdd()
{
InitializeComponent();
}
Car car = new Car();
private void button1_Click(object sender, EventArgs e)
{
Close();
}
private void btnSubmit_Click(object sender, EventArgs e)
{
car.setMake(txtMake.Text);
car.setModel(txtModel.Text);
car.setYear(txtYear.Text);
car.setPrice(txtPrice.Text);
listBox1.Items.Add(car);
}
private void listBox1_SelectedIndexChanged(object sender, EventArgs e)
{
}
}
}