Deriving from ComboBox won't allow toggling Enabled at design time with VB.NET
Posted on 2006-12-01
In VB.NET 2005, create the following derived component is a solution that has 2 projects, one for Library, one for test application.
Drag a JunkComboBox component from Toolbox to Form1.
Using the Properties window, toggle Enabled property back and forth. No Problem.
Then toggle Read_only property from False to True. It won't toggle.
Adding button with event handler does work.
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
JunkComboBox1.Read_only = Not JunkComboBox1.Read_only
The 500 point question is why not, and more importantly, how to add a property which toggles the enabled property at design time.
The key point is that it doesn't modify the enabled property at design time.
I also know that the signature should be: Public Property [Readonly] as Boolean, but don't want discussion to focus on that.
Public Class JunkComboBox
Public Property Read_only() As Boolean
Return Not Enabled
Set(ByVal value As Boolean)
Enabled = Not value