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.

ICustomTypeDescriptor support/Essential Suite Support

Thread ID:

Created:

Updated:

Platform:

Replies:

4636 May 22,2003 03:15 AM Jun 27,2005 06:59 AM General Discussion 4
loading
Tags: General Discussion
Apolon Ivankovic
Asked On May 22, 2003 03:15 AM

I've created a class that wraps the DateTime structure called TimeStamp. The reasoning behind the wrapping is the ability to support nullable date/time properties. My date/time properties now look like: public TimeStamp PlannedTime { get; set; } And code can check for null-ness as needed e.g. if ( entry.PlannedTime != null ) { TimeSpan diff = entry.PlannedTime .... etc. My base class implements ICustomTypeDescriptor to provide a customized PropertyDescriptor implementation that makes the PlannedTime property appear to return a DateTime. The customized property descriptor then does any conversion needed in the GetValue/SetValue calls. This approach worked well for another 3rd party grid, but failed for the Essential Grid. It didn't appear to use the specialized PropertyDescriptor (for binding) returned by ICustomTypeDescriptor calls. Fortunately, I resolved the problem by implementing IConvertable and handling cell set events within Syncfusion i.e. the TimeStamp properties appear as either DateTime value or null to the Syncfusion grid. My question is: Is there anyway I can ensure that customized PropertyDescriptor implementations are used by all of the Essential Suite controls (rather than the default reflected property descriptors). I worked around the problem for my TimeStamp case, but customized PropertyDescriptor functionality can be pretty useful for implementing arbitrary plumbing across a range of Business components.

Administrator [Syncfusion]
Replied On May 24, 2003 11:14 AM

Hi Apolon, I have forwarded this to the Grid team. Someone will get back to you on this. Best regards, Daniel

Administrator [Syncfusion]
Replied On May 26, 2003 07:37 AM

Apolon, with the existing grid version you only have to implement the ITypedList for your list in order to support ICustomTypeDescriptor. Attached find a sample that demonstrates usage of ICustomTypeDescriptor with Essential Grid Interesting code lines in the sample are: 1) Customer implements ICustomTypeDescriptor 2) ICustomTypeDescriptor.GetProperties adds CustomPropertyDescriptor to properties 3) CustomPropertyDescriptor is derived from PropertyDescriptor Please note the "new BrowsableAttribute(true)" attribute when calling base class constructor 4) Customer implements a parameterless ctor 5) Implement ITypedList in CustomersList. ITypedList.GetItemProperties looks as follows: public PropertyDescriptorCollection GetItemProperties(PropertyDescriptor[] listAccessors) { return TypeDescriptor.GetProperties(new Customer(), false); } I also looked into the grid source and we can make changes for future versions that make step 5 obsolete. Then your list does not have to provide a ITypedList.GetItemProperties() method anymore. But, there will still be some requirements: - Your list must provide a strongly typed indexer - The type must provide a parameterless constructor - The custom property must have a BrowsableAttribute(true) Stefan

Ranjit
Replied On June 22, 2005 10:42 AM

Hi, I have added a couple of properties to my inherited GGC. These properties store collections within themselves essentially. At run-time the user can load the control and change the properties using a property-descriptor form. The GridColumnCollection class inherits: ArrayList, IInsideCollectionEditorProperty The GridColumnCollection includes GridColumn class which inherits: DescriptorBase, IStandardValuesProvider Now, the issue is, on change of these properties, the control''s properties are not being set. How do I trigger an event on the control informing the collection value has changed? Thanks and Regards, Ranjit

Administrator [Syncfusion]
Replied On June 27, 2005 06:59 AM

Hi Ranjit, see the following methods for a sample how we do that within GridColumnDescriptor: public class GridColumnDescriptor : ... { GridColumnDescriptorCollection collection; /// /// Occurs when a property is changed. /// public event DescriptorPropertyChangedEventHandler PropertyChanged; /// /// Occurs before a property is changed. /// public event DescriptorPropertyChangedEventHandler PropertyChanging; /// /// Raises the event. /// /// A that contains the event data. protected virtual void OnPropertyChanged(DescriptorPropertyChangedEventArgs e) { if (this.Disposing) return; if (PropertyChanged != null) PropertyChanged(this, e); if (collection != null) collection.RaisePropertyItemChanged(this, e); } /// /// Raises the event. /// /// A that contains the event data. protected virtual void OnPropertyChanging(DescriptorPropertyChangedEventArgs e) { if (this.Disposing) return; if (PropertyChanging != null) PropertyChanging(this, e); if (collection != null) collection.RaisePropertyItemChanging(this, e); } [RefreshProperties(RefreshProperties.All), NotifyParentProperty(true)] public int MaxLength { get { return maxLength; } set { if (MaxLength != value) { OnPropertyChanging(new DescriptorPropertyChangedEventArgs("MaxLength")); maxLength = value; OnPropertyChanged(new DescriptorPropertyChangedEventArgs("MaxLength")); } else maxLength = value; } } /// /// Determines whether has been modified /// and should be serialized at design-time. /// /// true if contents were changed; false otherwise. public bool ShouldSerializeMaxLength() { return maxLength != -1; } /// /// Discards any changes for . /// public void ResetMaxLength() { MaxLength = -1; } internal void SetCollection(GridColumnDescriptorCollection collection) { this.collection = collection; this.tableDescriptor = collection._tableDescriptor; } The "collection" field is initialized when the column is added to a GridColumnDescriptorCollection, e.g. /// /// Adds an object to the end of the collection. /// /// The element to be added to the end of the collection. The value must not be a NULL reference (Nothing in Visual Basic). /// The zero-based collection index at which the value has been added. public int Add(GridColumnDescriptor value) { ... OnChanging(new ListPropertyChangedEventArgs(ListPropertyChangedType.Add, -1, value, null)); index = _inner.Add(value); value.index = index; value.SetCollection(this); OnChanged(new ListPropertyChangedEventArgs(ListPropertyChangedType.Add, index, value, null)); return index; } Stefan >Hi, > >I have added a couple of properties to my inherited GGC. These properties store collections within themselves essentially. > >At run-time the user can load the control and change the properties using a property-descriptor form. > >The GridColumnCollection class inherits: ArrayList, IInsideCollectionEditorProperty > >The GridColumnCollection includes GridColumn class which inherits: DescriptorBase, IStandardValuesProvider > >Now, the issue is, on change of these properties, the control''s properties are not being set. > >How do I trigger an event on the control informing the collection value has changed? > >Thanks and Regards, >Ranjit

CONFIRMATION

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.

;