Button Parameters in Windows Forms MessageBox (MessageBoxAdv)

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

OkCancel

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)

Ok cancel

YesNo

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

YesNoCancel

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)

Yes no cancel

RetryCancel

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)

Retry cancel

AbortRetryIgnore

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)

Abort retry ignore

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)

Icon support

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))

Icon support

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)

Right to left support

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

Details view support

Eg: Collapsed view

Collapsed view