| matt tag 2004-03-28, 10:28 pm |
| I've got a simple enumerated type and a property of that type on a
class
public enum SidingType {Clapboard, Beaded, Dutchlap};
public class HouseObject {
private SidingType FSidingType = SidingType.Dutchlap;
public SidingType SidingType {
get { return FSidingType; }
set { FSidingType = value; }
}
}
Now I create a form, and add a listbox and a button and an instance of
my new class. To bind the listbox to the enumerated type, I'm doing
the following:
private HouseObject obj;
private void Form1_Load(object sender, System.EventArgs e)
{
obj = new HouseObject();
listbox1.DataSource =
System.Enum.GetValues(obj.SidingType.GetType());
listbox1.DataBindings.Add("SelectedIndex", obj, "SidingType");
}
This populates the listbox with the members of the enumerated type,
and binds the SidingType property on the HouseObject class to the
listbox. It works in that I can change the default to any of the three
and it shows up correctly in the listbox. However, I cannot use the
listbox to CHANGE the value. When I click on another item in the
listbox, then tab out of the listbox, it automatically pops back to
whatever the property started off at. A breakpoint set in the
property's SET never gets hit. What's going on?
matt tag
|