Click here to Skip to main content
15,891,694 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Below is a inherited winforms control with two buttons.

The code, 'Me.ParentForm.AcceptButton' errors during design time.
I've tried the DesignerSerializationVisibility tag as well as the LicenseUsageMode with no luck to prevent it from running when opening a user control that is inherits the control below. How do I prevent the errors?

Public Class CalculationPanelBase

	<System.ComponentModel.DesignerSerializationVisibility(System.ComponentModel.DesignerSerializationVisibility.Hidden)> _
	Private Sub CalculationPanelBase_Load(sender As Object, e As EventArgs) Handles MyBase.Load
		'TODO:  Uncomment out during runtime to have the default button enabled
		If Not System.ComponentModel.LicenseManager.UsageMode.Equals(System.ComponentModel.LicenseUsageMode.Designtime) Then
			Me.ParentForm.AcceptButton = Calculate
		End If
	End Sub
	Protected Friend Overridable Sub Calculate_Click(sender As Object, e As EventArgs) Handles Calculate.Click
	End Sub
	Protected Friend Overridable Sub Reset_Click(sender As Object, e As EventArgs) Handles Reset.Click
	End Sub
	Public Overloads WriteOnly Property Visible As Boolean
		Set(value As Boolean)
			MyBase.Visible = value
		End Set
	End Property
End Class
Posted
Updated 7-Nov-12 6:02am
v3
Comments
onelopez 8-Nov-12 9:09am    
Try deleting the contents inside the obj forlder... sometimes it helps clear everything out and then rebuild the solution.

1 solution

After a bit more research, I found this is a prevalent issue with the work-around below. Basically, avoid having any handles clauses from your base class.
VB
Public Class CalculationPanelBase
  Private Sub CalculationPanelBase_Load(sender As Object, e As EventArgs) Handles MyBase.Load
		ParentForm.AcceptButton = CalculateMe
	End Sub
	Protected Friend Sub Calculate_Click(sender As Object, e As EventArgs) Handles CalculateMe.Click
		Calculate(sender, e)
	End Sub
	Protected Friend Overridable Sub Calculate(sender As Object, e As EventArgs)
	End Sub
	Protected Friend Sub Reset_Click(sender As Object, e As EventArgs) Handles ResetMe.Click
		Reset(sender, e)
	End Sub
	Protected Friend Overridable Sub Reset(sender As Object, e As EventArgs)
	End Sub
	Public Overloads WriteOnly Property Visible As Boolean
		Set(value As Boolean)
			MyBase.Visible = value
		End Set
	End Property
End Class
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900