I have a problem with the Bean properties when I use .NET classes (of Java Beans) that are compiled by IKVM. Searching with google for a few days, I found some sources that describe how to create custom property descriptors. Now I have my beans working with .NET databinding. This is a Bean-style class that I've used in testing:
public class Bean {
private string name;
public Bean() {
}
public string getName(){
return name;
}
public void setName(string value) {
name = value;
}
}
In the code below, BeanCollection is the class that implements ITypedList to simulate Bean getter/setter.
private void button1_Click(object sender,
EventArgs e) {
Bean[] b = new Bean[2];
b[0] = new Bean();
b[0].setName("hello");
b[1] = new Bean();
b[1].setName("Bean Binding in C#");
BeanCollection c;
c = new BeanCollection(b, typeof(Bean));
listBox1.DataSource = c;
listBox1.DisplayMember = "Name";
textBox1.DataBindings.Add("Text", c, "Name");
}
Here is the screenshot:
No comments:
Post a Comment