Use the Browsable Attribute when creating Form properties
The move towards treating forms as objects in VB is very welcome and very useful,
but there are some things that go on behind the scenes that you need to understand.
You might add a property to your form intending it to be used at runtime,
however if you then inherit from the form to create another form, the properties of
the first form will be available in the Property Window when the inherited form is
open in design mode.
The reason for this is the VB is allowing you to set the properties of the base class
so that the settings can be reflected in the inherited class right there in design mode.
Very useful, but not always what you want.
If a property only makes sense at run time then stop it appearing in the Design Mode
Property Window using the "Browsable" attribute, as follows:
Imports System.ComponentModel
Public Class MyForm
<Browsable(False)> _
Public Property MyProperty() As String
Of course if the property in the base form makes sense in design mode, and you want to see
the affect it has on inherited forms, then leave the property Browsable attribute as True.
- Login to post comments
