====== jMessageBox ====== The [[https://api.comfiletech.com/csharp/api/ComfileTech.jControls.jMessageBox.html|jMessageBox]] control is a composite control that can be used to display a message or question to the operator, and accept their response. Like most controls in the jControls library, it has a rich appearance, employing jControls' [[jcontrols:fills_and_borders:index|fill, border]], [[jcontrols:shape_and_cornerradii:index|corner radii]], and [[jcontrols:gloss_and_dropshadow:index#dropshadow_property|drop shadow]], along with a few additional features. ===== Button Properties ===== The jMessageBox control has 3 buttons, each of which are exposed as properties. |{{jmessagebox.png}}|{{jmessagebox_buttons.png}}| Because they are exposed as properties, their appearance can be customized in the designer. | {{jmessagebox_buttons_red.png}} | {{jmessagebox_buttons_red_properties.png}} | ===== Buttons Property ===== The Buttons property determines how the buttons appear, and what text they display. See the [[https://learn.microsoft.com/en-us/dotnet/api/system.windows.forms.messageboxbuttons|MessageBoxButtons]] enumeration. The following images show 3 of the many possible examples. | {{jmessagebox_ok.png}} | {{jmessagebox_ok_properties.png}} | | {{jmessagebox_okcancel.png}} | {{jmessagebox_okcancel_properties.png}} | | {{jmessagebox_yesnocancel.png}} | {{jmessagebox_yesnocancel_properties.png}} | ===== Button Text Properties ===== jMessageBox also exposes several properties for setting the buttons' text: * [[https://api.comfiletech.com/csharp/api/ComfileTech.jControls.jMessageBox.CancelText.html|CancelText]] * [[https://api.comfiletech.com/csharp/api/ComfileTech.jControls.jMessageBox.NoText.html|NoText]] * [[https://api.comfiletech.com/csharp/api/ComfileTech.jControls.jMessageBox.OKText.html|OKText]] * [[https://api.comfiletech.com/csharp/api/ComfileTech.jControls.jMessageBox.YesText.html|YesText]] * [[https://api.comfiletech.com/csharp/api/ComfileTech.jControls.jMessageBox.AbortText.html#ComfileTech_jControls_jMessageBox_AbortText|AbortText]] * [[https://api.comfiletech.com/csharp/api/ComfileTech.jControls.jMessageBox.RetryText.html|RetryText]] These provide the ability to customize the text that appears on the buttons according to the value of the Buttons property. As an illustrative example, consider how these properties can be used to display a message box in a language other than English. | {{jmessagebox_buttontext.png}} | {{jmessagebox_buttonstext_properties.png}} | ===== MessageLabel Property ===== The [[https://api.comfiletech.com/csharp/api/ComfileTech.jControls.jMessageBox.MessageLabel.html|MessageLabel]] property is a [[jcontrols:jlabel:index|jLabel]] that serves as the message of the jMessageBox. | {{jmessagebox_messagelabel.png}} | {{jmessagebox_messagelabel_properties.png}} | ===== Message Property ===== The [[https://api.comfiletech.com/csharp/api/ComfileTech.jControls.jMessageBox.Message.html#ComfileTech_jControls_jMessageBox_Message|Message]] property is an alias for the ''MessageLabel.Text'' property. ===== CaptionLabel Property ===== The [[https://api.comfiletech.com/csharp/api/ComfileTech.jControls.jMessageBox.CaptionLabel.html|CaptionLabel]] property is a [[jcontrols:jlabel:index|jLabel]] that serves as the title bar of the jMessageBox. |{{jmessagebox_captionlabel.png}}|{{jmessagebox_captionlabel_properties.png}}| ==== Text Property ==== The ''Text'' property is an alias for the ''CaptionLabel.Text'' property. ===== Showing the jMessageBox at Runtime ===== Typically the jMessageBox would be added to a [[jcontrols:jusercontrol:index|jUserConrol]] that is large enough to cover the screen. To show the messagebox, the jUserControl would then be added to a jForm at runtime displayed in front of all other controls with the [[https://learn.microsoft.com/en-us/dotnet/api/system.windows.forms.control.bringtofront|BringToFront]] method. Because the jUserControl covers the screen and is displayed in front of all other controls, it prevents the operator from touching any other control except the jMessageBox. When the operator responds to the jMessageBox by pressing one of its buttons, the jUserControl is then removed from the jForm, thus dismissing the jMessageBox. To see a demonstration of this technique, please see the Showcase Visual Studio project template. {{ https://downloads.comfiletech.com/jControls/videos/jmessagebox_demo.mp4?800x480 }}