using System;
using System.Windows.Forms;
using System.Drawing;
internal class Listed {
private int Val;
internal Listed(int x) {
Val = x;
}
public override string ToString() {
return Val.ToString();
}
}
internal class AnotherListed {
private int Val;
internal AnotherListed(int x) {
Val = x;
}
public int Value {
get { return Val; }
}
}
class ThisRocks : Form
{
private ListBox list1;
private ListBox list2;
public ThisRocks() {
list1 = new ListBox();
Listed[] ls = new Listed[10];
for (int i = 0; i < 10; i++) {
ls[i] = new Listed(i);
list1.Items.Add(ls[i]);
}
list2 = new ListBox();
list2.DisplayMember = "Value";
list2.Location = new Point(list1.Width, 0);
AnotherListed[] als = new AnotherListed[10];
for (int i = 10; i < 20; i++) {
als[i - 10] = new AnotherListed(i);
list2.Items.Add(als[i - 10]);
}
this.Size = new Size(300, 200);
this.Text = "Windows Forms Rocks!";
this.Controls.Add(list1);
this.Controls.Add(list2);
}
[ STAThread ]
public static void Main() {
Application.Run(new ThisRocks());
}
}
|