Button Parameters in Windows Forms MessageBox (MessageBoxAdv)
9 Oct 20237 minutes to read
Show function helps to display a MessageBoxAdv. This section explains regarding the parameters available in Show function.
Caption bar text
The text to display in the caption bar of the MessageBoxAdv.
Text
Represents the text which need to be displayed in the MessageBoxAdv.
Buttons
Provides various button combination like Ok, OkCancel, YesNo, YesNoCancel, RetryCancel and much more. By default, it shows only Ok button. MessageBoxButtons enumeration helps to set various button combination in MessageBoxAdv. Some of the available default buttons are as follows:
- Ok
- OkCancel
- YesNo
- YesNoCancel
- RetryCancel
- AbortRetryIgnore
Ok
This option helps to show the MessageBoxAdv with Ok button.
//MessageBox with Ok Button
MessageBoxAdv.Show(this, "Save changes?", "File Modified", MessageBoxButtons.OK, MessageBoxIcon.Question);
'MessageBox with Ok Button
MessageBoxAdv.Show(Me, "Save changes?", "File Modified", MessageBoxButtons.OK, MessageBoxIcon.Question)
Ok Cancel
This option helps to show the MessageBoxAdv with combination of Ok and Cancel buttons.
//MessageBox with combination of Ok and Cancel buttons.
MessageBoxAdv.Show(this, "Save changes?", "File Modified", MessageBoxButtons.OKCancel, MessageBoxIcon.Question);
'MessageBox with combination of Ok and Cancel buttons.
MessageBoxAdv.Show(Me, "Save changes?", "File Modified", MessageBoxButtons.OKCancel, MessageBoxIcon.Question)
Yes No
This option helps to show the MessageBoxAdv with combination of Yes and No buttons.
//MessageBox with combination of Yes and No buttons.
MessageBoxAdv.Show(this, "Save changes?", "File Modified", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
'MessageBox with combination of Yes And No buttons.
MessageBoxAdv.Show(Me, "Save changes?", "File Modified", MessageBoxButtons.YesNo, MessageBoxIcon.Question)
Yes No Cancel
This option helps to show the MessageBoxAdv with combination of Yes, No, and Cancel buttons.
//MessageBox with combination of Yes,No and Cancel buttons.
MessageBoxAdv.Show(this, "Save changes?", "File Modified", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question);
'MessageBox with combination of Yes,No And Cancel buttons.
MessageBoxAdv.Show(Me, "Save changes?", "File Modified", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question)
Retry Cancel
This option helps to show the MessageBoxAdv with combination of Retry and Cancel buttons.
//MessageBox with combination of Retry and Cancel buttons.
MessageBoxAdv.Show(this, "Save changes?", "File Modified", MessageBoxButtons.RetryCancel, MessageBoxIcon.Question);
'MessageBox with combination of Retry And Cancel buttons.
MessageBoxAdv.Show(Me, "Save changes?", "File Modified", MessageBoxButtons.RetryCancel, MessageBoxIcon.Question)
Abort Retry Ignore
This option helps to show the MessageBoxAdv with combination of Abort, Retry, and Ignore buttons.
//MessageBox with combination of Abort,Retry and Ignore buttons.
MessageBoxAdv.Show(this, "Save changes?", "File Modified", MessageBoxButtons.AbortRetryIgnore, MessageBoxIcon.Question);
'MessageBox with combination of Abort,Retry And Ignore buttons.
MessageBoxAdv.Show(Me, "Save changes?", "File Modified", MessageBoxButtons.AbortRetryIgnore, MessageBoxIcon.Question)
Icon
Supports to display wide variety of built-in icons and also empowered with loading custom icons. The default icons can be displayed in MessageBoxAdv by using MessageBoxIcon Enum and it is listed as follows:
- Asterisk
- Error
- Exclamation
- Hand
- Information
- None
- Question
- Stop
- Warning
The following code example illustrates adding Exclamation
icon in MessageBoxAdv.
//Icon Support
MessageBoxAdv.Show(this, "Save changes?", "Warning", MessageBoxButtons.OKCancel, MessageBoxIcon.Exclamation);
'Icon Support
MessageBoxAdv.Show(Me, "Save changes?", "Warning", MessageBoxButtons.OKCancel, MessageBoxIcon.Exclamation)
The following code example illustrates adding custom icons in MessageBoxAdv.
//Icon Support
MessageBoxAdv.Show(this, "Save changes?", "Warning", MessageBoxButtons.OKCancel, image, new Size(50,50));
'Icon Support
MessageBoxAdv.Show(Me, "Save changes?", "Warning", MessageBoxButtons.OKCancel, image, New Size(50,50))
Right to left support
MessageBoxAdv elements can be aligned in right-to-left layout. It is laid out from the right to left when RightToLeft property is set to true. Its default value is false.
MessageBoxAdv.RightToLeft = RightToLeft.Yes;
MessageBoxAdv.Show(this,"Save changes?", "File Modified", MessageBoxButtons.YesNo,MessageBoxIcon.Question);
MessageBoxAdv.RightToLeft = RightToLeft.Yes
MessageBoxAdv.Show(Me,"Save changes?", "File Modified", MessageBoxButtons.YesNo,MessageBoxIcon.Question)
Details view
This pane helps to view the detail message about the text shown in the MessageBoxAdv. It also provide options to show / hide the detail pane.
MessageBoxAdv.Show(this, "Save changes?", "Warning", MessageBoxButtons.OKCancel, image, new Size(50, 50), "Do you want to save your changes to respective file location?");
MessageBoxAdv.Show(Me, "Save changes?", "Warning", MessageBoxButtons.OKCancel, image, New Size(50, 50), "Do you want to save your changes to respective file location?")
Eg: Detail view
Eg: Collapsed view
Resizing support
MessageBoxAdv allows you to adjust the size of the control at run time by dragging the gripper at bottom right. It can be achieved by using the CanResize property. The default value is false.
MessageBoxAdv.CanResize = true;
MessageBoxAdv.CanResize = True
NOTE