====== 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 [[.:jmessagebox#open_method|Open method]] in response to the operator's input.
===== Properties =====
==== Button Properties ====
Each of the three [[.:jbutton|buttons]] are exposed as properties.
{{ .:messageboxchildcontrols.png?nolink |}}
Because they are exposed as properties their layout, appearance, and behavior can be individually customized.
{{ .:messageboxcustombutton.png?nolink |}}
Or, they can be customized by simply selecting them in the designer.
{{ :jcontrols_cf35:messageboxeditbuttons.mp4?854x480 }}
==== 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 [[.:jmessagebox#open_method|Open Method]]. This can be particularly useful when creating a multilingual UI.
|{{ .:messageboxbuttontext.png?nolink |}}|{{ .:messageboxbuttontextproperties.png?nolink |}}|
==== MessageLabel Property ====
The ''MessageLabel'' property exposes the [[.:jLabel|label]] that displays the message. Like the [[.:jmessagebox#button_properties|buttons]], it's layout, appearance, and behavior can be customized.
{{ .:messageboxcustomlabel.png?nolink |}}
==== 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 handleResult, string message);
public void Open(Action handleResult, string message, string caption);
public void Open(Action 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 [[.:jmessagebox#messagelabel_property|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 [[https://msdn.microsoft.com/en-us/library/system.windows.forms.control.capture%28v=vs.90%29.aspx|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 [[https://msdn.microsoft.com/en-us/library/system.windows.forms.dialogresult%28v=vs.90%29.aspx|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 [[https://msdn.microsoft.com/en-us/library/system.windows.forms.dialogresult%28v=vs.90%29.aspx|DialogResult]] corresponding to that button press will be displayed in the ''_resultLabel''.
void DisplayResult(DialogResult result)
{
_resultLabel.Text = result.ToString();
}
void _okButton_Click(object sender, EventArgs e)
{
_messageBox.Open(DisplayResult, "Press OK Button", ((Control)sender).Text, jMessageBox.Buttons.OK);
}
void _okCancelButton_Click(object sender, EventArgs e)
{
_messageBox.Open(DisplayResult, "Press OK or Cancel Button", ((Control)sender).Text, jMessageBox.Buttons.OKCancel);
}
void _yesNoButton_Click(object sender, EventArgs e)
{
_messageBox.Open(DisplayResult, "Press Yes or No Button", ((Control)sender).Text, jMessageBox.Buttons.YesNo);
}
void _yesNoCancelButton_Click(object sender, EventArgs e)
{
_messageBox.Open(DisplayResult, "Press, Yes, No, or Cancel Button", ((Control)sender).Text, jMessageBox.Buttons.YesNoCancel);
}
{{ .:messagebox.mp4?854x480 }}