WinForms Layout Control — Five New Features to Expect in v20.2

WinForms Team Blog
10 September 2020

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

Showcase Your Apps on DevExpress.com

Highlight your business app and share your development experiences with the DevExpress community. To include your app in our upcoming App Showcase, please forward an application screenshot to clientservices@devexpress.com and tell us which DevExpress products you currently use within your organization.
6 comment(s)
Benjamin Hofmann
Benjamin Hofmann
#1 looks great!
10 September 2020
Marc Greiner (DevExpress MVP)
Marc Greiner (DevExpress MVP)
Great addition to this wonderfull and unique control. Well done!
10 September 2020
thehill
thehill

 Highlight Non-Resizable Elements - will save a lot of headaches

11 September 2020
Steven Vissers
Steven Vissers

Highlighting and Serialization is awesome. 


Serialization will affect me for sure. At this moment I do all with PropertyAllowed.


Did you also improve the general performance for large large layouts?

11 September 2020
Dmitry (DevExpress)
Dmitry (DevExpress)

@Steven

Hi, could you please explain your issue in greater detail? Here in comments, or in a private Support Center ticket. What are those performance difficulties that you face? Thanks.

11 September 2020
Jose Vargem
Jose Vargem

Eu adoro a melhoria no layout da tabela.

obrigado


25 September 2020

Please login or register to post comments.