Kada izaberem jedno ime kliknem ba button 2 izbacim ime i ubacim ga u list box. Sa button 3 vracam iz list box ime i broj koji sam ubacila u prvobitno. Imam problem sa button 1, a klikanjem na button 2 mi se napise ime koje sam sama napisala
Code:
public struct Student
{
private string name;
private int number;
public Student(string Name, int Number)
{
name = Name;
number = Number;
}
public string Name
{
get
{ return name;}
set
{ name = value; }
}
public int Number
{
get
{return number;}
set
{number = value;}
}
public override string ToString()
{
return base.ToString();
}
}
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
al.Add(new Student("Sonja", 1));
al.Add(new Student("Maria", 2));
al.Add(new Student("Anna", 3));
al.Add(new Student("Lena", 4));
al.Add(new Student("Maja", 5));
}
private ArrayList al = new ArrayList();
private void button1_Click(object sender, EventArgs e)
{
al.Add("Sonja");
textBox1.Select();
textBox2.Select();
}
private void button2_Click(object sender, EventArgs e)
{
al.Add("Sonja");
al.Add("Maria");
listBox1.DataSource = null;
listBox1.DataSource = al;
}
private void button3_Click(object sender, EventArgs e)
{
al.Add(al);
}
private void button4_Click(object sender, EventArgs e)
{
Close();
}
}
}
public struct Student
{
private string name;
private int number;
public Student(string Name, int Number)
{
name = Name;
number = Number;
}
public string Name
{
get
{ return name;}
set
{ name = value; }
}
public int Number
{
get
{return number;}
set
{number = value;}
}
public override string ToString()
{
return base.ToString();
}
}
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
al.Add(new Student("Sonja", 1));
al.Add(new Student("Maria", 2));
al.Add(new Student("Anna", 3));
al.Add(new Student("Lena", 4));
al.Add(new Student("Maja", 5));
}
private ArrayList al = new ArrayList();
private void button1_Click(object sender, EventArgs e)
{
al.Add("Sonja");
textBox1.Select();
textBox2.Select();
}
private void button2_Click(object sender, EventArgs e)
{
al.Add("Sonja");
al.Add("Maria");
listBox1.DataSource = null;
listBox1.DataSource = al;
}
private void button3_Click(object sender, EventArgs e)
{
al.Add(al);
}
private void button4_Click(object sender, EventArgs e)
{
Close();
}
}
}