Hey to all of you.
I've been doing a really exhausting project about inheritence and composition; and after I finished coding classes, I started doing the windows form, and here, I really got overwhelmed, as I couldn't find out how to add an object property (object.name) to the listbox.
I've tried and tried, but no matter what I do, I always get stuck having some problem with listbox object adding, either It only adds the 1st object, then other elements are duplicated, or the listbox is never shown at all.
Here's a code snippet for Form1.cs :
namespace Map
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
public ArrayList countries = new ArrayList();
private void button1_Click(object sender, EventArgs e)
{
Country c = new Country(cntrynm.Text, comboBox1.Text, Convert.ToDouble(areatxt.Text), Convert.ToInt32(numericUpDown1.Value), nibor1.Text, nibor2.Text, nibor3.Text, Convert.ToDouble(xcontxt.Text), Convert.ToDouble(ycontxt.Text), Convert.ToDouble(zcontxt.Text));
countries.Add(c);
listBox1.Items.Add(countries.Add(c.Country_Name));
listBox1.Items.Clear();
for (int i = 0; i < countries.Count; i++)
{
countries.Add(c);
countries[i]= new Country(cntrynm.Text, comboBox1.Text, Convert.ToDouble(areatxt.Text), Convert.ToInt32(numericUpDown1.Value), nibor1.Text, nibor2.Text, nibor3.Text, Convert.ToDouble(xcontxt.Text), Convert.ToDouble(ycontxt.Text), Convert.ToDouble(zcontxt.Text));
listBox1.Items.Add((Country)countries[i]);
(Country)countries[i] = c;
listBox1.Items.Add((Country)countries[i].);
}
}
here's the download link for those of you who are intrested in giving me a hand:
http://www.ziddu.com/download/19354518/Map.zip.html">http://www.ziddu.com/download/19354518/Map.zip.html[^]
(only 66 KB)
P.S: there are lots of classes and coding, so everything's set well, and you only have to correct for me the
Form1.cs
coding, specificly the listbox.
so, please if you have any idea who to use objects and object's properties with listbox adding, thanks for the help forwards
you can send me the corrected version to my email: obzajd@mail.com
Thanks for listening
^]