Back to Devexpress

Numeric Ranges

windowsforms-11761-controls-and-libraries-editors-and-simple-controls-range-control-numeric-ranges.md

latest3.5 KB
Original Source

Numeric Ranges

  • Oct 29, 2020
  • 3 minutes to read

The Range Control’s data visualization specifics are covered in the Range Control topic. The current document shows how to set up a Range Control to display numeric ranges and allow end-users to select them.

The Range Control provides a drawing surface where a Range Control Client visualizes its data. To add support for numeric (integer, float, double or decimal) ranges, you need to assign a NumericRangeControlClient object to the RangeControl.Client property.

Design-Time Example

  1. Drop a RangeControl control from the Toolbox onto the form.

  2. Right click the Range Control and select Add Numeric Client.

  3. Once the Numeric Range Control Client is added, the Range Control displays a ruler, tickmark lines and selection thumbs.

  4. After adding a NumericRangeControlClient, its settings become accessible via the RangeControl.ClientOptions property. You can use this property to customize the available options.

  5. By default, the NumericRangeControlClient.Minimum, NumericRangeControlClient.Maximum and NumericRangeControlClient.RulerDelta property values are of the integer type. To display a range of the double, decimal or float type, you need to set these properties to the required double, decimal or float values.

The currently selected range can be obtained via the RangeControl.SelectedRange property. You can also use this property to change the selected range from code.

Runtime Example

The following code shows how to set up a NumericRangeControlClient to select a range of the double type between 5.5 and 10.5, with the minimum step set to 0.5.

csharp
using DevExpress.XtraEditors;

// Set up Numeric Range Control Client.
NumericRangeControlClient numClient = new NumericRangeControlClient();
numClient.Maximum = 10.5D;
numClient.Minimum = 5.5D;
numClient.RulerDelta = 0.5D;
// Assign Client to Range Control.
rangeControl1.Client = numClient;
// Modify selected range from code.
rangeControl1.SelectedRange.Maximum = 7;
rangeControl1.SelectedRange.Minimum = 6;
vb
Imports DevExpress.XtraEditors

' Set up Numeric Range Control Client.
Dim numClient As NumericRangeControlClient = New NumericRangeControlClient()
numClient.Maximum = 10.5R
numClient.Minimum = 5.5R
numClient.RulerDelta = 0.5R
' Assign Client to Range Control.
rangeControl1.Client = numClient
' Modify selected range from code.
rangeControl1.SelectedRange.Maximum = 7
rangeControl1.SelectedRange.Minimum = 6

The result is displayed below.