继承的属性在设计器中不可编辑
我有一个基表单类,它提供一个看起来像这样的新属性。
Public Class BaseForm
Private _HappyTime As Boolean
Public Property HappyTime() As Boolean
Get
Return _HappyTime
End Get
Set(ByVal value As Boolean)
_HappyTime = Value
End Set
End Property
End Class
<Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated()> _
Partial Class BaseForm
Inherits System.Windows.Forms.Form
<System.Diagnostics.DebuggerNonUserCode()> _
Protected Overrides Sub Dispose(ByVal disposing As Boolean)
Try
If disposing AndAlso components IsNot Nothing Then
components.Dispose()
End If
Finally
MyBase.Dispose(disposing)
End Try
End Sub
Private components As System.ComponentModel.IContainer
<System.Diagnostics.DebuggerStepThrough()> _
Private Sub InitializeComponent()
components = New System.ComponentModel.Container
Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font
Me.Text = "BaseForm"
End Sub
End Class
现在,当我在新表单上继承 BaseForm 时,HappyTime 属性在属性窗口中显示为 false,并且不可编辑。
我在一个全新的解决方案中重新创建了这个 BaseForm 和 Inheriting Form,并且 HappyTime 属性是可编辑的并且按预期工作。由于某些原因,在现有项目(需要进行这些更改)中,它的行为不正常。
这让我相信这与我的项目配置有关。除了创建一个新项目并将所有代码移入其中之外,有人对此有任何见解吗?
环境信息: .Net Framework 3.5、Visual Studio 2010、Win7 x64
I have a base form class that is providing a new property that looks Like this
Public Class BaseForm
Private _HappyTime As Boolean
Public Property HappyTime() As Boolean
Get
Return _HappyTime
End Get
Set(ByVal value As Boolean)
_HappyTime = Value
End Set
End Property
End Class
<Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated()> _
Partial Class BaseForm
Inherits System.Windows.Forms.Form
<System.Diagnostics.DebuggerNonUserCode()> _
Protected Overrides Sub Dispose(ByVal disposing As Boolean)
Try
If disposing AndAlso components IsNot Nothing Then
components.Dispose()
End If
Finally
MyBase.Dispose(disposing)
End Try
End Sub
Private components As System.ComponentModel.IContainer
<System.Diagnostics.DebuggerStepThrough()> _
Private Sub InitializeComponent()
components = New System.ComponentModel.Container
Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font
Me.Text = "BaseForm"
End Sub
End Class
Now when I inherit the BaseForm on a new form, the HappyTime property displays in the properties window as false, and is uneditable.
I've recreated this BaseForm and Inheriting Form in an entirely new soloution and, the HappyTime property is editable and works as expected. For some reason in the existing project (where these changes need to be made) it's not behaving properly.
This leads me to believe that it has something to do with the configuration of my project. Does anybody have any insight into this, short of creating a new project and moving all the code into it?
Environment Information:
.Net Framework 3.5, Visual Studio 2010, Win7 x64
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在重新创建的解决方案中,_HappyTime 属性是私有还是受保护?我认为,如果您在此解决方案中将其更改为“受保护”,它就会起作用。
In the recreated solution, is the _HappyTime property Private or Protected? I think that if you just change it to Protected in this solution, it'll work.