WinForms Tips & Tricks - What You May Have Missed

WinForms Team Blog
04 July 2018

Every DevExpress release introduces some new major features that receive lots of attention in the run-up to the release. DirectX hardware acceleration, Fluent Design, vector icons and skins - you must have heard about those, if you’ve been reading our blogs and newsletters.

In addition to these big new features, we also continuously work on smaller details. In this post, I will point out a few features that you may have missed so far - hopefully they will make your developer lives easier!

Workspace Manager

You are probably aware that all major DevExpress controls - including Ribbon, Bars, Data Grid, Layout Manager, Document Manager and others - have a pair of SaveLayout and RestoreLayout methods. These helpers implement runtime settings persistence, storing changes to the registry, an XML file or a stream. In a large real-world application, this system still requires some code to be written to coordinate the persistence of the large number of individual controls. We offer a more elegant solution that automates this process further: the Workspace Manager.

This component saves and restores presets called workspaces, which include layout settings for all supported DevExpress WinForms UI Controls in a hierarchy, usually for the main form. It even provides dedicated Toolbar and Ribbon items that enable end-users to capture their own workspaces, load and save them.

Workspace Manager

If necessary, you can restrict end users from loading any but the predefined workspaces, and there are also mechanisms that filter the set of components considered for persistence.

Find documentation for the WorkspaceManager here.

Input Box

When you need to show a message with a single editor so that a user can type in a value or select one from a drop-down list, you could create a custom User Control and display it using an XtraDialog for UI consistency. But it is even easier to use our XtraInputBox instead:

var result = XtraInputBox.Show("Enter a new value", "Change Settings", "Default");

Input Box with Text Editor

The Input Box occupies the sweet spot between a simple message box and a full-fledged dialog. You can choose any DevExpress editor to display, and customize it if required.

Input Box with Date Editor

Documentation for the XtraInputBox is available here.

In addition to the Input Box, the DevExpress WinForms Subscription includes all the tools to replace standard message boxes, dialogs, hints, alerts, toast notifications, and file/folder selection dialogs with their skinned counterparts. You can see a complete list on this documentation page.

Behaviors

When our new Skin Editor was released, many customers asked us to make its Magnifier available as a separate control, since it complements color pickers nicely. We decided to introduce the Magnifier as a Behavior that can be attached to any ColorEdit descendant, providing an extra button for the editor that brings up the Magnifier.

Magnifier

There are currently twelve other Behaviors that extend or modify an attached control. For instance, the Clock Behavior styles a LabelControl or a digital Gauge as a clock:

Clock Behavior

The Stub Glyph Behavior provides placeholder icons for data records, layout items and tabs.

Stub Glyph Behavior

Note that the Persistence Behavior offers an additional approach for the settings persistence functionality described above! Documentation for all Behaviors can be found here.

If you come across a scenario that forces you to customize DevExpress controls in the same manner over and over again, please let us know and we will consider adding a new Behavior to get your job done more quickly and make the customization available to others.

Did you already know the three features mentioned in this post? We have a few more items and we will make at least a second post if you’re interested! Please share any thoughts you have, or let us know about other “easy to miss” features you have discovered yourself.

Free DevExpress Products – Get Your Copy Today

The following free DevExpress product offers remain available. Should you have any questions about the free offers below, please submit a ticket via the DevExpress Support Center at your convenience. We’ll be happy to follow-up.
Steve Sharkey
Steve Sharkey

Over the many years I've been using DevExpress components I often find the big, headline, releases  - whilst good don't quite impact/improve things for me as the sum of these sorts of "minor" releases as they are often related to things that you use often and hence feel the benefits many times over. They are also usually much easier to implement quickly in solutions - so instant value for money.

Looking forward to another post.

4 July 2018
Johnny K
John K

i missed that input box!!!!!!!!!! so cool! so simple! many likes!

but the new time edit control is annoying :(

4 July 2018
Dmitry (DevExpress)
Dmitry Korovin (DevExpress)

@Johnny K

I don't think we've done anything to the Time Edit control recently. Can you please clarify what new control did you mean, and what's annoying about it?

And just a quick reminder - if you come across any issues, you can always contact our Support Team and they will do their best to help you.

4 July 2018
renejdm
renejdm

Thank you. Please write more blogs like this.

4 July 2018
tony hasselbacher
tony hasselbacher

i noticed in v18.1, that the popup menu has been overhauled.. it goes to a designer now instead of a clunky editor.

4 July 2018
DIP_Michel
DIP_Michel

I do like the idea of the Workspace Manager. But it also brings a lot of troubles.

The Workspace Manager saves a lot more information than it should e.g. Text or Caption properties. This can produce funny results if you change the language of your application back and forth.

I know you can solve this with filtering the properties. But the time you need to find the right property with the right value or even having to ask the support is not fun.

The Workspace Manager should be limited to properties that can actually be changed by the user.

5 July 2018
Dmitry (DevExpress)
Dmitry Korovin (DevExpress)

@DIP_Michel

Thanks for the feedback. Controls supported by the Workspace Manager usually have Restore...Text properties (for instance, DockManager.SerializationOptions.RestoreDockPanelsText). If you disable this setting, item captions won't be loaded when you load layout settings from a workspace.

5 July 2018
Neal
Neal

Thank you for making it so hard to switch to WPF. I don't want to leave my Winforms :)

5 July 2018
Junior Thurler
Junior Thurler

Very useful tips! You should do more post about this precious tips!

11 July 2018

Please login or register to post comments.