A form is described by a FormDefinition (namespace TheTechIdea.Beep.Editor.Forms.Models). It holds FormName, a list of Blocks, a Menu, and AutoCreateBlocksFromDefinition, which is true by default.

Block definition

A BlockDefinition names a block and the data it reads. Its members include BlockName, Caption, ConnectionName, EntityName, PresentationMode, ParentBlock, MasterKeyPropertyName, ForeignKeyPropertyName, QueryAllowed, InsertAllowed, UpdateAllowed, DeleteAllowed, QueryString, an Entity of type BlockEntityDefinition, and a Navigation setting of type BlockNavigationDefinition.

A PresentationMode of Grid, Table, Tabular or MultiRecord makes the WinForms block host show a grid instead of single record field presenters.

Fields

Each field is a BlockFieldDefinition in Entity.Fields. The IDE writes these members when they are set: FieldName, Label, DataType, ControlType, Order, Size, IsRequired, AllowDBNull, IsPrimaryKey, IsUnique, IsIndexed, IsAutoIncrement, IsReadOnly, IsCheck, EditorKey, BindingProperty, Category, Description, NumericPrecision, NumericScale, Width, IsVisible, IsEnabled, PropertyClassName, FormatMask, DefaultValue, CopyValueFromItem, and the per operation flags QueryAllowed, InsertAllowed and UpdateAllowed.

What registration applies

When a FormsManager is assigned to the host, DefinitionBlockRegistrar.RegisterAll registers every block of the definition, masters first. It skips this when AutoCreateBlocksFromDefinition is false. For each block it:

  • opens the data source named by ConnectionName and resolves the entity structure and row type;
  • uses the authored IsPrimaryKey fields when the data source reports no primary key;
  • applies QueryAllowed, InsertAllowed, UpdateAllowed and DeleteAllowed, and turns QueryString into the block's default where clause;
  • applies FormatMask, DefaultValue, CopyValueFromItem, the per field allowed flags and the property class to each field, and turns Order into a tab order by rank.

When a property class is named, a value is taken in this order: the field definition, then the property class, then the item itself.

A block that cannot be registered is skipped and the reason is written to the editor log. The messages are listed on the troubleshooting page.

Records start empty

Blocks load no rows when the form opens. After the manager is assigned, call ExecuteQueryAsync for the block and then MoveFirstAsync.

Without a definition

A block can also be set up in code. SetupBlockAsync(blockName, connectionName, entityName, isMasterBlock, ct) opens the data source and registers the block.