VB Form Designer errors on custom control
I have created a class that holds information about an event.
The date the event triggers, if it is a repeating event, and the repeat interval.
I have created a custom listbox control to display my events. It has a property for getting and setting a list of events to display. The property has the data type of: List(Of cEvent) where cEvent is my Event Class.
When I add the control to a Form and then build the project, the form editor errors - and will no longer display or allow changes to the forms design.
It seems to be that the designer is trying to set the value of the property, from within the forms designer.vb file. It does this by creating a resource in the forms resource file(.resx) and assigns it to the property. This is unsuccessful because it can't create a resource entry with a proper datatype. The datatype is set to null, which can't be converted to a valid type.
Is there something I can do to keep VB from trying to assign a default value to this property. Or is there something I can do to my class or control to tell the form designer how to handle this?
Interesting problem. I think this might be a bug, in the forms designer.
When it tries to store a default value for the property in the forms resource file, and the data type is complex, like my List(Of cEvent). It ends up putting in a null value, which it cannot convert back to the correct data type.
I solved this problem by modifying the custom control. I split the EventList property into two overloaded routines. An EventList Sub that takes the List(Of cEvent) as a paramater, and an EventList Function that Returns a List(Of cEvent).
The EventList Sub takes the passed List(Of cEvent) and loads the listbox with the events.
The EventList Function returns a List(Of cEvent) with the Items that are currently displayed by the listbox.
The only change to the syntax was for Setting the EventList:
MyListBox.EventList = myEvents
Retreiving the Items from the list box stayed the same:
myEvents = MyListBox.EventList
Last edited by Ron Weller; 05-17-2012 at 06:44 PM.
By Benjamin in forum .NET
Last Post: 04-05-2006, 03:06 AM
By Sync in forum VB Classic
Last Post: 12-07-2005, 01:21 AM
By Arthur Wood in forum .NET
Last Post: 10-28-2002, 12:10 PM
By Thomas Eyde in forum .NET
Last Post: 12-22-2001, 02:13 PM
By Willy Van den Driessche in forum VB Classic
Last Post: 09-24-2001, 01:44 PM
Top DevX Stories
Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL