User Tools

Site Tools

한국어

jcontrols_cf35:jmessagebox

jMessageBox

jMessageBox is a composite control that can be used to display a message or question to the operator, and accept their response.

Although visible in the Visual Studio designer, jMessageBox'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 message box, use the Open method in response to the operator's input.

Properties

Button Properties

Each of the three 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.

Button Text Properties

jMessageBox also exposes 4 properties for setting the buttons' text: CancelText, NoText, OKText, and YesText. These provide the ability to customize the text that appears for the buttons according to the jMessageBox.Buttons enumeration passed to the Open Method. This can be particularly useful when creating a multilingual UI.

MessageLabel Property

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

Text Property

The Text property sets the title of the message box. By default, it is empty, so no text is displayed.

Text Features

jMessageBox 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 message box.

Methods

Open Method

public void Open(Action<DialogResult> handleResult, string message);
public void Open(Action<DialogResult> handleResult, string message, string caption);     
public void Open(Action<DialogResult> handleResult, string message, string caption, jMessageBox.Buttons buttons);

handleResult - The callback to execute when the operator presses one of the 3 buttons
message - The message to display in the MessageLabel
caption - The text to display as the title of the message box.
buttons - The button configuration to use; choose from OK, OKCancel, YesNo, or YesNoCancel

The Open method will display the message box, and capture the mouse/touch input so anywhere outside the message box will not receive operator input. When any one of the buttons are pressed, the message box will be closed, and the handleResult callback will be called with the appropriate DialogResult according to the button that was pressed.

Example

In the following example, there are 4 buttons (_okButton, _okCancelButton, _yesNoButton, and _yesNoCancelButton) each corresponding to one of 4 button configurations in the jMessageBox.Buttons enumeration. There is also a label, _resultLabel, that will display the result after the message box is closed.

Pressing one of the buttons on the form will open the message box with the appropriate button configuration. When the operator presses one of the message box buttons, the DialogResult corresponding to that button press will be displayed in the _resultLabel.

void DisplayResult(DialogResult result)
{
    _resultLabel.Text = result.ToString();
}
 
private void _okButton_Click(object sender, EventArgs e)
{
    _messageBox.Open(DisplayResult, "Press OK Button", ((Control)sender).Text, jMessageBox.Buttons.OK);
}
 
private void _okCancelButton_Click(object sender, EventArgs e)
{
    _messageBox.Open(DisplayResult, "Press OK or Cancel Button", ((Control)sender).Text, jMessageBox.Buttons.OKCancel);
}
 
private void _yesNoButton_Click(object sender, EventArgs e)
{
    _messageBox.Open(DisplayResult, "Press Yes or No Button", ((Control)sender).Text, jMessageBox.Buttons.YesNo);
}
 
private void _yesNoCancelButton_Click(object sender, EventArgs e)
{
    _messageBox.Open(DisplayResult, "Press, Yes, No, or Cancel Button", ((Control)sender).Text, jMessageBox.Buttons.YesNoCancel);
}

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