0
Reply

DataBinding the UI control to the array element ?

Sky Patrick

Sky Patrick

Feb 2 2007 8:57 PM
1.8k
 

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 :)