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>, out FormDesignerFormatException?).
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>, out FormDesignerFormatException?).
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
ClientHeight
The form's ClientHeight designer property, in points: the height of its window's client area. The designer block writes it in twips, 20 to a
point. null when the designer block does not set it, or sets it to something that is not a number.
public double? ClientHeight { get; }
Property Value
ClientLeft
The form's ClientLeft designer property, in points: the distance of its client area from the left of the desktop. The designer block writes it in twips,
20 to a point. null when the designer block does not set it, or sets it to something that is not a number.
public double? ClientLeft { get; }
Property Value
ClientTop
The form's ClientTop designer property, in points: the distance of its client area from the top of the desktop. The designer block writes it in twips,
20 to a point. null when the designer block does not set it, or sets it to something that is not a number.
public double? ClientTop { get; }
Property Value
ClientWidth
The form's ClientWidth designer property, in points: the width of its window's client area. The designer block writes it in twips, 20 to a point.
null when the designer block does not set it, or sets it to something that is not a number.
public double? ClientWidth { get; }
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
DesignerText
The text of a Visual Basic 6.0 form's designer: the module's source from its first line through the designer block's End line, with the
VERSION header, the Object lines and the Begin … End block, and without the Attribute lines and the code that
follow it. null for a VBA UserForm and for another designer.
public string? DesignerText { get; init; }
Property Value
Remarks
It travels with the descriptor, with State, so that the library that hosts the form reads the form's properties from it where no file of the workspace is at hand.
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 (StateOf(string?, ReadOnlyMemory<byte>)), opaque here: for a VBA UserForm, the
compound file its .frx keeps; for a Visual Basic 6.0 form, the whole .frx. 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 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.