A few days ago, we released our v20.2 Early Access Preview. If you missed the announcement, please refer to the following post for more information: WinForms — Early Access Preview (v20.2).
In this post, I want to summarize new features we expect to ship for our WinForms Layout/Data Layout Control in our v20.2 release cycle.
Highlight Non-Resizable Elements
If you’ve used the DevExpress WinForms Layout Control, you know that it offers nearly unlimited layout customization options. Unfortunately, this flexibility comes at a cost, as the control requires that you specify numerous settings - settings that may conflict with one another.
If you ever tried to resize a layout item and could not figure out why it won't budge, you will love this small enhancement. With v20.2, our design time and runtime customization form automatically highlights items that have reached their minimum/maximum size (and thus cannot be resized any further).
In the figure above, "Contact Title" cannot be enlarged because the neighboring TextEdit ("Contact Name") has reached its minimum width. The pink highlight allows you to quickly determine the item that is affecting resize operations.
If you want to limit element size, we recommend that you use standard Control.MinimumSize
and Control.MaximumSize
properties for controls hosted inside these items. You can also set SizeConstraints
to "Custom" and limit the size of an entire Layout Item, but we do not recommend this approach. First, it is less flexible - it requires that you set both width and height limits, whereas standard properties allow you to limit only one control dimension. Second, this approach may lead to undesirable results if the Layout Item text changes (for instance, when you localize an app to another language). We have created a Knowledge Base article that discusses this matter in greater depth (size calculation logic used in the Layout Control) and explains how to address common usage scenarios/customer requirements: DevExpress WinForms Cheat Sheet - LayoutControl Resizing Mechanism.
New API in Data Layout Control
Data Layout Control is a data-aware version of our standard Layout Control. It automatically builds a layout based on your data source, and displays the first data source record. To display values of other records, previous versions required that you implement a custom data navigator. In v20.2 you will be able to use embedded Data Layout Control API to navigate through data items.
CurrentRecordPosition
- assign a data row index to this property to display values of this row in our WinForms Data Layout Control;CurrentRecord
- returns an object (for instance, a DataRow) whose values are currently displayed in the Data Layout Control;GetCurrentRecordFieldValue(string fieldName)
- allows you to retrieve the value of a cell that belongs to the current row and the specific data source column;SetCurrentRecordFieldValue(string fieldName, object value)
- allows you to edit data source records;RecordCount
- returns the total number of data source records.
All methods are implemented for the DataLayoutControl
class.
Hyperlink Support
We recently added support for HTML tags (including HTML images) in both Layout Item and Layout Group captions. This means you can now add hyperlinks to these captions.
To respond to hyperlink clicks, handle the LayoutControl.HyperlinkClick
event. This event is a single entry point for any clicked hyperlink, and the event "e.Item" parameter allows you to identify which Layout Item triggered the event.
layoutControl.HyperlinkClick += OnHyperlinkClick;
void OnHyperlinkClick(object sender, LayoutItemHyperlinkClickEventArgs e) {
if(e.Item == layoutControlItem1)
System.Diagnostics.Process.Start(e.Link);
}
Row and Column Visibility Settings in Table Layout Mode
ColumnDefinition
and RowDefinition
objects for the Table Layout Mode now include the Visible
property. Invisible columns or rows are hidden alongside their Layout Items. If an item spans multiple rows or columns, and you hide one of them, the item reduces its size but remains visible.
Advanced Serialization Options
We recently received a Support Center ticket whose author saved form layouts to files, and compared them in v18.1.7 and v19.2.7. Turns out, the size of these files grew by 30-40% because the Layout Control serialized more of its properties (for instance, Appearance settings). In v20.2 you will be able to use the LayoutControl.OptionsSerialization
property to choose which Layout Controls settings to save into a file or stream.
This property exposes the following Boolean options:
- StoreAppearance
- StoreSpaceOptions
- StoreEnabledState
- StoreText
- StorePrintOptions
- DiscardOldItems