R
Rich Hackett
Hi, I'm trying to write a web control which is basically a calendar
control(need to add extra functionality later)
I have the first phase working eg a calendar control is rendered and
works as expected but because I inherit webcontrol not Calendar I
don't get the properties for it in the VS designer.
I found several articles on this around using the prefilterproperties
function but I am struggling to get this to work.
here's the code
Protected Overrides Sub PreFilterProperties(ByVal properties As
System.Collections.IDictionary)
Dim props As PropertyDescriptorCollection
MyBase.PreFilterProperties(properties)
props = TypeDescriptor.GetProperties(GetType(Calendar))
Dim propitem As PropertyDescriptor
Dim runtimeAttributes As
System.componentmodel.AttributeCollection
Dim attrs() As Attribute
For Each propitem In props
runtimeAttributes = propitem.Attributes
ReDim attrs(runtimeAttributes.Count - 1)
runtimeAttributes.CopyTo(attrs, 0)
properties(propitem.Name) =
TypeDescriptor.CreateProperty(GetType(Calendar), propitem.Name, attrs)
Next
It works fine for all the properties which are common eg backcolor,
font ... but not for the custom calendar properties
DayHeaderStyle,TitleFormat.. all return "Object reference not set to
an instance of an object." in the property window. There are also
some properties which don't appear against the normal Calendar
properties presumeably these are hidden. Any ideas?
control(need to add extra functionality later)
I have the first phase working eg a calendar control is rendered and
works as expected but because I inherit webcontrol not Calendar I
don't get the properties for it in the VS designer.
I found several articles on this around using the prefilterproperties
function but I am struggling to get this to work.
here's the code
Protected Overrides Sub PreFilterProperties(ByVal properties As
System.Collections.IDictionary)
Dim props As PropertyDescriptorCollection
MyBase.PreFilterProperties(properties)
props = TypeDescriptor.GetProperties(GetType(Calendar))
Dim propitem As PropertyDescriptor
Dim runtimeAttributes As
System.componentmodel.AttributeCollection
Dim attrs() As Attribute
For Each propitem In props
runtimeAttributes = propitem.Attributes
ReDim attrs(runtimeAttributes.Count - 1)
runtimeAttributes.CopyTo(attrs, 0)
properties(propitem.Name) =
TypeDescriptor.CreateProperty(GetType(Calendar), propitem.Name, attrs)
Next
It works fine for all the properties which are common eg backcolor,
font ... but not for the custom calendar properties
DayHeaderStyle,TitleFormat.. all return "Object reference not set to
an instance of an object." in the property window. There are also
some properties which don't appear against the normal Calendar
properties presumeably these are hidden. Any ideas?