Class FormDescriptor
What a form module's designer declares: the form's own class and designer properties, and its controls.
public sealed record FormDescriptor : IEquatable<FormDescriptor>
- Inheritance
-
FormDescriptor
- Implements
- Inherited Members
Remarks
FormDescriptor is the designer model shared by every platform component that needs to know what a form declares, whichever designer wrote it: the language server, to compose the form's class and analyse its code-behind, and a form designer (an IDE), to agree with it. Read one with Read(string?, ReadOnlyMemory<byte>).
Constructors
FormDescriptor(string, FormDesignerKind, FormControlClass, IReadOnlyDictionary<string, string>, IReadOnlyList<FormControlDescriptor>)
What a form module's designer declares: the form's own class and designer properties, and its controls.
public FormDescriptor(string Name, FormDesignerKind Kind, FormControlClass Class, IReadOnlyDictionary<string, string> Properties, IReadOnlyList<FormControlDescriptor> Controls)
Parameters
NamestringThe name of the form, as its designer block names it (
Begin {…} ExampleView).KindFormDesignerKindThe designer that wrote the form.
ClassFormControlClassThe class of the form itself (
MSForms.UserForm,VB.Form).PropertiesIReadOnlyDictionary<string, string>The form's own designer properties, by name (case-insensitive), as written in the module's designer block: a string value without its quotes, any other value as written, without its trailing comment.
ControlsIReadOnlyList<FormControlDescriptor>The form's controls, in the order the designer persisted them; a container's controls are its Children.
Remarks
FormDescriptor is the designer model shared by every platform component that needs to know what a form declares, whichever designer wrote it: the language server, to compose the form's class and analyse its code-behind, and a form designer (an IDE), to agree with it. Read one with Read(string?, ReadOnlyMemory<byte>).
Properties
Caption
The form's Caption designer property, or null when the designer block does not set it.
public string? Caption { get; }
Property Value
Class
The class of the form itself (MSForms.UserForm, VB.Form).
public FormControlClass Class { get; init; }
Property Value
Controls
The form's controls, in the order the designer persisted them; a container's controls are its Children.
public IReadOnlyList<FormControlDescriptor> Controls { get; init; }
Property Value
Kind
The designer that wrote the form.
public FormDesignerKind Kind { get; init; }
Property Value
Name
The name of the form, as its designer block names it (Begin {…} ExampleView).
public string Name { get; init; }
Property Value
Properties
The form's own designer properties, by name, case-insensitively (whatever comparer the given dictionary had: one that went over the wire has none).
public IReadOnlyDictionary<string, string> Properties { get; init; }
Property Value
ShowModal
The form's ShowModal designer property, or null when the designer block does not set it. A designer
writes it only when it is not its default, True.
public bool? ShowModal { get; }
Property Value
- bool?
StartUpPosition
The form's StartUpPosition designer property (1 is CenterOwner), or null when the designer
block does not set it or sets it to something that is not a number.
public int? StartUpPosition { get; }
Property Value
- int?
State
The designer's state of the form, as the library that hosts it loads it: for a VBA UserForm, the compound file its .frx keeps
(StateOf(string?, ReadOnlyMemory<byte>)), opaque here. Empty for a form whose designer keeps none, and for one read without its companion file.
public ReadOnlyMemory<byte> State { get; init; }
Property Value
Remarks
What a form declares is read from it once (Controls); the state itself travels with the descriptor so that whatever runs the form - the environment host, which has no file of the workspace - can hand it to the form host as it is.
Methods
AllControls()
Every control of the form, at any depth, in the order the designer persisted them.
public IEnumerable<FormControlDescriptor> AllControls()
Returns
DeclaredControls()
The controls the form's class has a field for, one per name, in the order the designer persisted them.
public IEnumerable<FormControlDescriptor> DeclaredControls()
Returns
Remarks
Every control is one, at any depth: the controls of a Frame and of a MultiPage's pages are fields of the form, like the form's own
(UserForm1.OptionButton1). The pages of a MultiPage are not (MS-VBA: UserForm1.Page1 is "Method or data member not found", and the
form's Controls collection does not have them; Excel-measured), and are reached through their MultiPage (MultiPage1.Pages("Page1")).
The controls of a Visual Basic 6.0 control array share their name, which is the one field.