
How to bind Array of Objects to Window Forms Control
Hi,
Try binding to a ArrayList.
Public workers As ArrayList
I initialize that array like this:
workers=new arraylist
workers.add(New Cworker("Agent", "Smith"))
workers.add(New Cworker("Neo", "Anderson"))
where constructor simply sets properties FirstName and LastName
then I try to bind:
TextBox2.DataBindings.Add(New Binding("text", workers, "FirstName"))
Ken
----------------
Quote:
> Such declared array has IList interface implemented (MSDN):
> Public workers() As Cworker
> correct?
> IList is only requirement for binding to window form controls (MSDN)
> correct?
> I initialize that array like this:
> ReDim workers(1)
> workers(0) = New Cworker("Agent", "Smith")
> workers(1) = New Cworker("Neo", "Anderson")
> where constructor simply sets properties FirstName and LastName
> then I try to bind:
> TextBox2.DataBindings.Add(New Binding("text", workers, "FirstName"))
> all is described in MSDN and seems be right:
> data source object implements iList,
> data member is property of current object
> but run-time error message is: "Can't bind to property on column FirstName
> on datasource
> I can't guess what's wrong...
> unfortunately examples are only for native data objects like DataTable or
> DataSet
> there is no example (or I've not found it) for binding custom IList object
> HELP!