Posted 14 years ago
by Jose Simas
Hi,
I am trying to add a number of categories to the PropertyGrid and under each one of them add a few properties. I am able to add the categories but I am unable to add items under each one of them.
I created a class that inherits from DataFactory and I am overriding GetProperties and GetDataAccessors based on this post:
http://www.actiprosoftware.com/support/forums/viewforumtopic.aspx?ForumTopicID=3929
The overrides are:
protected override IList<IPropertyDataAccessor> GetProperties(object value, DataFactoryOptions options)
{
//not sure what I should be doing here but it is abstract.
return null;
}
public override IList<IDataAccessor> GetDataAccessors(object[] values, DataFactoryOptions options)
{
var cols = values[0] as DataSetColumn[];
if (cols == null) return null;
var list = new List<IDataAccessor>();
for (int i = 0; i < cols.Length; i++)
{
var cat = new CategoryDataAccessor(cols[i].Label);
list.Add(cat);
var item = new PropertyDescriptorDataAccessor(cat, "Max");
item.Value = cols[i].DataSetColumnStats.MaxValue;
list.Add(item);
}
return list;
}
The code fails at the line "item.Value = cols[i].DataSetColumnStats.MaxValue;" with the exception "Object reference not set to an instance of an object." (StackTrace at the bottom of the post). The source of the exception is in the item.Value property (or deeper).
I must be missing a step here. Would you please let me know what I have to do?
StackTrace:
at ActiproSoftware.Windows.Controls.PropertyGrid.Primitives.ReflectionPropertyDescriptor.get_PropertyType()
at System.ComponentModel.PropertyDescriptor.get_Converter()
at ActiproSoftware.Windows.Controls.PropertyGrid.Primitives.PropertyDescriptorDataAccessor.set_ValueInternal(Object value)
at ActiproSoftware.Windows.Controls.PropertyGrid.Primitives.CachedPropertyDataAccessorBase.set_Value(Object value)
at GeneXproTools.Controls.Data.DataManagement.MyFactory.GetDataAccessors(Object[] values, DataFactoryOptions options)
I am trying to add a number of categories to the PropertyGrid and under each one of them add a few properties. I am able to add the categories but I am unable to add items under each one of them.
I created a class that inherits from DataFactory and I am overriding GetProperties and GetDataAccessors based on this post:
http://www.actiprosoftware.com/support/forums/viewforumtopic.aspx?ForumTopicID=3929
The overrides are:
protected override IList<IPropertyDataAccessor> GetProperties(object value, DataFactoryOptions options)
{
//not sure what I should be doing here but it is abstract.
return null;
}
public override IList<IDataAccessor> GetDataAccessors(object[] values, DataFactoryOptions options)
{
var cols = values[0] as DataSetColumn[];
if (cols == null) return null;
var list = new List<IDataAccessor>();
for (int i = 0; i < cols.Length; i++)
{
var cat = new CategoryDataAccessor(cols[i].Label);
list.Add(cat);
var item = new PropertyDescriptorDataAccessor(cat, "Max");
item.Value = cols[i].DataSetColumnStats.MaxValue;
list.Add(item);
}
return list;
}
The code fails at the line "item.Value = cols[i].DataSetColumnStats.MaxValue;" with the exception "Object reference not set to an instance of an object." (StackTrace at the bottom of the post). The source of the exception is in the item.Value property (or deeper).
I must be missing a step here. Would you please let me know what I have to do?
StackTrace:
at ActiproSoftware.Windows.Controls.PropertyGrid.Primitives.ReflectionPropertyDescriptor.get_PropertyType()
at System.ComponentModel.PropertyDescriptor.get_Converter()
at ActiproSoftware.Windows.Controls.PropertyGrid.Primitives.PropertyDescriptorDataAccessor.set_ValueInternal(Object value)
at ActiproSoftware.Windows.Controls.PropertyGrid.Primitives.CachedPropertyDataAccessorBase.set_Value(Object value)
at GeneXproTools.Controls.Data.DataManagement.MyFactory.GetDataAccessors(Object[] values, DataFactoryOptions options)