A DataBound ListBox

This example shows a ListBox bound to an ArrayList as the DataSource.



import clr clr.AddReference('System.Windows.Forms')

from System.Windows.Forms import (   Form, Application, ListBox,    DockStyle )

from System.Collections import ArrayList

class DataBoundListBoxExample(Form):

def __init__(self): self.Text = 'Data Bound ListBox Example' box = ListBox box.Dock = DockStyle.Fill self.Controls.Add(box) array = ArrayList for i in xrange(100): array.Add(i) box.DataSource = array Application.Run(DataBoundListBoxExample)

Back to Contents.