WinForms Tips & Tricks — Virtual Keyboard and New Customer Cases

WinForms Team Blog
07 July 2021

In this post we'll share some of the more interesting customer requests we've received over the past couple of months. And as a bonus, we’ll show you how to create a virtual keyboard for your app.

Customer Usage Scenarios

  • How to check whether the XtraMessageBox is currently visible (T1009121)
    The DevExpress XtraMessageBox is a replacement for the standard WinForms MessageBox. It allows you to apply DevExpress skins to message boxes used within your app. It also offers extras such as the ability to embed a “Do not show again" checkbox, apply HTML-inspired text formatting (including Image and P tags for multi-line text blocks with images), incorporate button customizations, etc. This ticket explains how to check whether the DevExpress Message Box is visible at runtime.
  • How to display previews of saved layouts (T1006287)
    Having multiple layout versions for users to choose from is a great customization option with one minor downside: you need to apply a layout version to see what it looks like. This ticket explains how to use the DevExpress ScreenCaptureHelper to create snapshots of various layouts and use these images as layout previews.
  • How to implement a 3-state Toggle Switch (T1006935)
    DevExpress ToggleSwitch has two states: On and Off. If you want a third, "Indeterminate" state, you need to use our WinForms CheckEdit instead. This ticket explains how to customize a CheckEdit so that it mirrors the appearance of our WinForms Toggle Switch.
  • How to remove the sub-menu depth limit in DXPopupMenu (T1009286)
    If you ever decide to create a DXPopupMenu with sub-menus inside sub-menus inside sub-menus, you will discover that our default menu nesting limit equals "5". To remove this limit, change the value of the hidden static DXPopupMenu.MaxSubMenuLevel property.
  • How to copy a selected Data Grid row with the "Plus" Data Navigator button (T1008218)
    The DevExpress WinForms Data Grid can display a Data Navigator to simplify grid navigation (browse grid records). The Navigator's "+" button initializes a new blank row. We were recently asked whether this button's behavior can be modified to copy a selected row into a new row and to activate the Edit Form to instantly edit the record. This ticket explains how to achieve this requirement.
  • How to obtain the color values of Conditional Formatting templates (T1007515)
    Conditional Formatting — available across DevExpress data-aware controls — allows you to highlight values that meet specified criteria (for example, paint the five lowest cell values in red). If you need to obtain exact color values for these rule patterns, use the FormatPredefinedAppearances.Default.Find method. See this ticket for more information in this regard.
  • How to copy Grid Summary Item values (T1007122)
    Summaries can display a standard context menu. This menu allows users to change summary type, or add and remove summary items. You can access this menu to populate it with custom entries as needs dictate. For instance, your custom menu item can allow users to copy a summary item value.
  • How to get handles for all rows loaded in Data Grid Instant Feedback mode (T1006630)
    In Instant Feedback mode, our WinForms Data Grid loads its rows asynchronously. To identify which rows are already loaded, you can either iterate through all row handles and call the IsRowLoaded method for each (this strategy works best for smaller data sources with a limited number of records), or handle the RowLoaded event (this strategy offers better performance on large data sources).
  • How to use different editor setups for regular and AutoFilterRow cells (T1005595)
    This ticket explains how to use a three-state CheckEdit for the Data Grid AutoFilterRow and maintain two-state editor for standard data rows (only "Checked" and "Unchecked" states with no "Indeterminate").
  • How to play SWF videos (T985088)
    Back in the old days, our support engineers used to attach flash videos (swf format) to their answers. If you encounter an old support ticket and want to view an old flash tutorial, simply follow the instructions outlined in this ticket.

How to Create a Virtual Keyboard

As a bonus for this month’s WinForms Tips & Tricks post, we’ll show you how to use our WinForms SvgImageBox editor to emulate a virtual keyboard.

To help get things started, we've created a GitHub sample that you can use as a reference: SvgImageBox – Virtual keyboard from SVG file. Copy the sample SVG keyboard image and change the following parameters to suit your requirements:

  • the number of keys inside the "keys" section;
  • the X and Y coordinates of individual keys;
  • key IDs;
  • total SVG image size.
<?xml version="1.0" encoding="utf-8"?>
<svg width="Image_Width" height="Image_Height" ...>
  <defs>
    <g id="key">
      <path .../>
      <text ...>
        <tspan ...">[key]</tspan>
      </text>
    </g>
  </defs>
  <g id="keys">
    <use id="Key_ID" href="#key" transform="matrix(1, 0, 0, 1, Key_X, Key_Y)/>
    ...
  </g>
</svg>

You can modify these parameters in any Notepad-like editor.

When your keyboard image is ready, load it into the SvgImageBox control and copy-and-paste the code from our GitHub sample. This universal code works regardless of SVG keyboard layout. The SendKeys.Send method sends key values to the active text field. As such, you don't need to bind your keyboard to individual input boxes.

FREE DevExpress Xamarin UI Controls

Deliver high-impact native mobile apps with our feature-rich Data Grid, Scheduler, Chart, TabView, Editors, and utility controls. Reserve your free copy today!
Heiko Mueller
Heiko Mueller
Very helpfull... Thank you very much!
8 July 2021

Please login or register to post comments.