User Tools

Site Tools

한국어

jcontrols_cf35:jnumpad

jNumpad

jNumpad is a composite control of jButtons and jLabels that can be used to input numeric data.

Although visible in the Visual Studio designer, jNumpad's Visible property is false by default, so it will not display when the form loads on the Windows CE device. Rather, to display the numpad, use the Open method in response to the operator's input.

Properties

Button Properties

Each of the individual buttons are exposed as properties.

Because they are exposed as properties their layout, appearance, and behavior can be individually customized.

Or, they can be customized by simply selecting them in the designer.

ValueDisplay Property

The ValueDisplay property exposes the label that displays the entered value. Like the buttons, it's layout, appearance, and behavior can be customized.

Text Property

The Text property sets the title of the numpad.

Text Features

jNumpad employs the same text features used by many of the other controls in the jControls CF35 library including ForeColor, TextOffset, TextAlignment, and TextWrap. See Text Features for more information. These features will affect the title of the numpad.

Methods

Open Method

public virtual void Open(Action<string> handleResult, string initialValue, string title, bool clearOnFirstEdit)
public virtual void Open(Action<string> handleResult, string initialValue, string title)

handleResult - The callback to execute when the operator presses the Enter button
initialValue - The initial value to display in the numpad's ValueDisplay property
title - The text to display as the title of the numpad.
clearOnFirstEdit - True to clear the initial value on the first input from the operator, false to immediately append the operators input.

The Open method will display the numpad, and capture the mouse/touch input so anywhere outside the numpad will not receive operator input. The Enter button will close the numpad and call the handleResult callback. The Cancel button will close the numpad without calling the handleResult callback.

Example

The following example has two jLabels: _intLabel for integer input and _floatLabel for floating point input. They will both use the same jNumpad, _numpad. When either label it clicked/touched, their corresponding Click event handlers will be called, which in turn call _numpad's Open method.

After the the operator clicks/touches the Enter button to accept input, either the SetIntLabel method is called to update _intLabel's value, or the SetFloatLabel method is called to update _floatLabel's value.

private void SetIntLabel(string numpadResult)
{
    _intLabel.Text = int.Parse(numpadResult).ToString();
 
    // Input is finished, re-enable decimal point
    _numpad.DotButton.Enabled = true;
}
 
private void _intLabel_Click(object sender, EventArgs e)
{
    // Disable decimal point for integers
    _numpad.DotButton.Enabled = false;
 
    // Open the numpad.  Call SetIntLabel when the Enter button is pressed.
    _numpad.Open(SetIntLabel, _intLabel.Text, "Integer");
}
 
private void SetFloatLabel(string numpadResult)
{
    _floatLabel.Text = float.Parse(numpadResult).ToString();
}
 
private void _floatLabel_Click(object sender, EventArgs e)
{
    // Open the numpad.  Call SetFloatLabel when the Enter button is pressed.
    _numpad.Open(SetFloatLabel, _intLabel.Text, "Floating Point");
}

jcontrols_cf35/jnumpad.txt · Last modified: 2016/04/14 11:03 (external edit)