Hi,
Sorry for letting you wait for so long. Based on my understanding, in your
custom object colleciton each object has a property which is enum type, you
have managed to display the enum names in the combobox, but you failed to
modify it.
For combobox, it will not allow us to modify certain item in the bound
collection, it just used for select certain item in the collection.
I have used the following code snippet to do a test:
public enum CustomColor
{
white=0,
red=1,
yellow=2,
blue=3
};
public class TestClass
{
private CustomColor _testprop=CustomColor.white;
public CustomColor testprop
{
get
{
return _testprop;
}
set
{
_testprop=value;
}
}
}
TestClass [] arr;
private void button1_Click(object sender, System.EventArgs e)
{
arr=new TestClass[4];
for(int i=0;i<4;i++)
{
arr[i]=new TestClass();
arr[i].testprop=(CustomColor)Enum.Parse(typeof(CustomColor),
Enum.GetName(typeof(CustomColor), i));
}
this.comboBox1.DataSource=arr;
this.comboBox1.ValueMember="testprop";
this.comboBox1.DisplayMember="testprop";
}
private void button2_Click(object sender, System.EventArgs e)
{
for(int i=0;i<4;i++)
{
Console.WriteLine(this.arr[i].testprop.ToString());
}
}
If we select item with text "white" in the dropdownlist, then if we modify
the text "white" as "red", combobox will not modify the current bound
item's value to "red"'s value, but just change the current bound item index
to first item with text "red". This is combobox's default behavior.
Combobox is used to select certain item in a collection, not for modifying
an item's property.
For modifying issue, I think you may refer to other winform controls, such
as textbox or datagrid etc..
If I misunderstand you, please feel free to tell me, thanks.
============================================================
Thank you for your patience and cooperation. If you have any questions or
concerns, please feel free to post it in the group. I am standing by to be
of assistance.
Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! -
www.microsoft.com/security This posting is provided "as is" with no warranties and confers no rights.