In Visual Studio 2005, using NetAdvantage for .NET 2008 Vol. 2 CLR 2.0 :
I have created a base form, MyBaseForm, which contains an UltraComboEditor, cboColors.
I then created another form, DataEntry, which inherits from MyBaseForm. I am able to view DataEntry in the designer, which shows cboColors from MyBaseForm, as expected. However, when I add code to handle the EditorButtonClick event in DataEntry, such as
Private Sub cboColors_EditorButtonClick(ByVal sender As System.Object, ByVal e As Infragistics.Win.UltraWinEditors.EditorButtonEventArgs) Handles cboColors.EditorButtonClick ' do stuff.End Sub
I get a warning on the Error List tab "The event EditorButtonClick is read-only and cannot be changed.", File = nothing, Line = 0, Column = 0.DataEntry form no longer shows up in the designer. Instead, there is the message
-------------------------------One or more errors encountered while loading the designer. The errors are listed below. Some errors can be fixed by rebuilding your project, while others may require code changes.
The event EditorButtonClick is read-only and cannot be changed. Hide
at System.ComponentModel.Design.EventBindingService.EventPropertyDescriptor.SetValue(Object component, Object value)at System.ComponentModel.Design.Serialization.CodeDomSerializerBase.DeserializeAttachEventStatement(IDesignerSerializationManager manager, CodeAttachEventStatement statement)at System.ComponentModel.Design.Serialization.CodeDomSerializerBase.DeserializeStatement(IDesignerSerializationManager manager, CodeStatement statement) -------------------------------
The program runs without any errors. It's simply impossible to see the DataEntry form anymore without commenting out the EditorButtonCode event code. Is there any way to fix this problem?
It turns out that the "problem" has to do with the way controls on a base form are handled on the child form. This holds true for both VS controls and Infragistics control in both VS2K5 and VS2K8.
Looking at DataEntry in the designer and clicking on cboColors, all the events are grayed out indicating that they are not available. So it is not possible to create an event handler for any event of this control through the designer. Creating the event handler manually is possible, the code compiles and runs without a problem, but the form is no longer viewable in the designer. So, to get around this, I created a protected overridable event handler in the base form that does nothing:
and a protected overrides sub in DataEntry. Note that there is no event handler (Handles cboColors.EditorButtonClick) with this sub.
Protected Overrides Sub cboColors_EditorButtonClick(ByVal sender As System.Object, ByVal e As Infragistics.Win.UltraWinEditors.EditorButtonEventArgs) ' do stuff.End Sub
Using this method, it is now possible to create controls on a base form and handle its events in the child form. I know that this seems a bit kludgy, but it actually does get the job done.