For example instead of doing the ("\\n-----------------");
for a MessageBox.Show();
function, is there an in-build horizontal line generator similar to the HTML <hr>
?
A messagebox is a simple element for showing plain text. It does not have much design features.
However you can easily create a new form, put in its text and show it using Form.ShowDialog
. Now you can add any design-element you want by chosing it in the toolbox, eg by using a 2px label as shown here .
You could also implement the syntax you know from MessageBox
by using a static method:
public class CustomMessageBox : Form
{
private readonly static instance = new CustomMessageBox();
private DialogResult result = DialogResult.No;
private CustomMessageBox()
{
btnOK.DialogResult = DialogResult.OK;
btnCancel.DialogResult = DialogResult.Cancel;
this.AcceptButton = btnOK;
this.CancelButton = btnCancel;
}
public static DialogResult Show(string text)
{
return instance.ShowDialog();
}
}
Create a form, and send the message in your constructor or in function. And set the available buttons that you want to see... That way you can handle the response-buttons
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.