We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy.
Unfortunately, activation email could not send to your email. Please try again.

IBindingLIst DataSource problem, plese help me

Thread ID:





12950 Apr 15,2004 08:26 PM Apr 18,2004 05:53 AM Windows Forms 2
Tags: GridControl
Administrator [Syncfusion]
Asked On April 15, 2004 08:26 PM

Hello, I have a problem with GridDataBoundGrid: I''m using a custom DataSource of a collection that implements IBindingList. The collection contains Class Person''s objects, this following is class Person: public enum EGender { Man = 1, Woman } public class Person { private string name; private EGender gender; public string Name { get { return this.name; } set { this.name = value; } } public EGender Gender { get { return this.gender; } set { this.gender = value; } } } I construct a DataSource for the "Gender" Column . DataTable table = new DataTable(); table.Columns.Add("Value", typeof(EGender)); table.Columns.Add("Description", typeof(string)); DataRow row = table.NewRow(); row["Value"] = EGender.Man; row["Description"] = "I''m a man"; table.Rows.Add(row); row = table.NewRow(); row["Value"] = EGender.Woman; row["Description"] = "I''m a woman"; table.Rows.Add(row); gridDataBoundGrid1.Binder.InternalColumns["Gender"].StyleInfo.DataSource = table; gridDataBoundGrid1.Binder.InternalColumns["Gender"].StyleInfo.ValueMember = "Value"; gridDataBoundGrid1.Binder.InternalColumns["Gender"].StyleInfo.ValueMember = "Description"; The problem: When I change the value of gender(for example, select "I''m a woman"), there is a exception "Object type can not be converted to target type". if my collection implements ITypedList interface, I will catch a exception "Invalid cast from ystem.Int32 to EGender" please help me, thank u very much

Administrator [Syncfusion]
Replied On April 16, 2004 12:58 AM

I assume the Gender column in the grid''s DataSource is also of type EGender, correct? If so, try also setting; gridDataBoundGrid1.Binder.InternalColumns["Gender"].StyleInfo.CellValueType = typeof(EGender);

Administrator [Syncfusion]
Replied On April 18, 2004 05:53 AM

thank u very much! I have already added gridDataBoundGrid1.Binder.InternalColumns["Gender"].StyleInfo.CellValueType = typeof(EGender); to my code, it does not work either, I add a Breakpoint at the PropertyDescriptor.SetValueSetValue( object component, object value ); Method the value is a Int32 type object which value is 1 or 2, is the value passed by GridDataBoundGrid?If I don''t construct a DataSource for the "Gender" Column, the value will be a EGender type and the value will be {EGender.Man} or {EGender.Woman} (PS:My program returns a custom class named MyPropertyDescriptor : PropertyDescriptor collentcion in ITypedList.GetItemProperties Method, so I can watch the value passed by Grid) please help me... thanks...


This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.