Sky Patrick

Sky Patrick

  • NA
  • 3
  • 0

DataBinding the UI control to the array element ?

Feb 2 2007 8:57 PM
 

Hi ~

For the databinding for the control class

i.e. Control.DataBindings.Add(string propertyName,object dataSource,string dataMember)

for the parameter of dataSource and dataMember, how can i bind the value of the control to the specific in array

e.g. if i have a class

public class Person{
public object[] extras

}

then i want to bind the control with the second element in Person.extras i.e. Person.extras[1]

i try the following ways, but not success

controlObj.DataBindings.Add("Text, person.extras, new object[] {1});

and

controlObj.DataBindings.Add("Text", person, "extras[1]");

The Control i need to being binding to is allow to bind the single value only, such as TextBox, can just bind to a sigle value. But ListBox can bind to a list or array because it allow multiple to display in the control

Thank :)