Blocks and items
What a block definition holds and what registration reads from it.
In this documentation
- Beep.Forms
- Architecture
- Authoring in the Object Navigator
- WinForms runtime
- WPF runtime
- End-to-end example
- Remote UI limitations
- Overview
- Context menus
- Blocks and items
- Triggers
- Lists of values
- Validation
- Master detail
- Navigation and queries
- Alerts, editors and timers
- Calling other forms
- Form menus
- Hosting in WinForms step by step
- Hosting in WPF step by step
- Saving and loading forms
- The IDE toolbar and dialogs
- Troubleshooting
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
ConnectionNameand resolves the entity structure and row type; - uses the authored
IsPrimaryKeyfields when the data source reports no primary key; - applies
QueryAllowed,InsertAllowed,UpdateAllowedandDeleteAllowed, and turnsQueryStringinto the block's default where clause; - applies
FormatMask,DefaultValue,CopyValueFromItem, the per field allowed flags and the property class to each field, and turnsOrderinto 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.