Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to allow copying message on MessageBox

Tags:

c#

.net

wpf

How can I allow selecting and copying of text from MessageBox in WPF?

like image 516
ns12345 Avatar asked Jan 26 '11 20:01

ns12345


People also ask

How to copy from message box?

Here's a simple trick that you may not be aware of. To copy text from message box in Windows 10, simply press the Ctrl+C hotkey to copy the message box text and you are done! Then, do not click the OK button, press the CTRL + C hotkey instead. The contents of the message box will be copied to the clipboard.

Which of the following is default button of MessageBox control?

MessageBox with Default Button By default, the first button is the default button. The MessageBoxDefaultButton enumeration is used for this purpose and it has the following three values. The following code snippet creates a MessageBox with a title, buttons, and an icon and sets the second button as a default button.


2 Answers

If you don't need selecting text as a requirement, just use System.Windows.Forms.MessageBox. It maps to the system-default one which already allows copying its contents with Ctrl+C.

like image 174
Joey Avatar answered Oct 14 '22 10:10

Joey


You can just use Ctrl+C while the message box has focus, but it will give you a lot more text than just the error message.

e.g.

    MessageBox.Show("Message", "Message Title", MessageBoxButton.OK); 

Would copy and paste as:

    ---------------------------     Message Title      ---------------------------     Message     ---------------------------     OK        --------------------------- 
like image 29
danielcooperxyz Avatar answered Oct 14 '22 09:10

danielcooperxyz