Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
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 7-Nov-12 5:57am
-Dr_X-1.7K
Edited 7-Nov-12 6:02am
v3
Comments
jlopez788 at 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

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

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.
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
  Permalink  

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

  Print Answers RSS
0 OriginalGriff 253
1 Maciej Los 205
2 Nguyen.H.H.Dang 190
3 Peter Leow 185
4 arvind mepani 162


Advertise | Privacy | Mobile
Web03 | 2.8.140709.1 | Last Updated 8 Nov 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid