Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

c# select text from messagebox.show popup

Tags:

i've been searching on google and stackoverflow for 2hours now. There has to be something i am just simply overlooking. Is there an easy way to make the text selectable in a messagebox? As of right now when i call a MessageBox.Show() i can not copy the text displayed. Why not? how would i set the text to be copy able?

my code:

//catch all exceptions         catch (Exception ex)         {             MessageBox.Show(ex.Message);             //throw;         } 

I want to be able to select the error message that comes out so a user can send it to me and i can troubleshoot their issue. Any help is greatly appreciated.

EDIT: Can not use the crtl-c method. My users are not able to grasp that concept. Need to highlight with mouse and right click to select option. THank you!

EDIT: For reference what i ended up doing is using a mixture of the answers. I created a popup window with a single button and upon the button action i copied to the clipboard. Its not perfect but with the right label it works well enough for now. Thank you all for the suggestions!

//catch all exceptions             catch (Exception ex)             {                 //MessageBox.Show(ex.Message);                 MessageBoxButtons buttons = MessageBoxButtons.OK;                 DialogResult result;                  // Displays the MessageBox.                  result = MessageBox.Show(ex.Message + "\n\nClick OK button to copy to clipboard", "Error", buttons);                  if (result == System.Windows.Forms.DialogResult.OK)                 {                      Clipboard.SetText(ex.Message);                     //throw;                  }              } 
like image 623
toosweetnitemare Avatar asked Oct 20 '11 18:10

toosweetnitemare


People also ask

What C is used for?

C programming language is a machine-independent programming language that is mainly used to create many types of applications and operating systems such as Windows, and other complicated programs such as the Oracle database, Git, Python interpreter, and games and is considered a programming foundation in the process of ...

What is the full name of C?

In the real sense it has no meaning or full form. It was developed by Dennis Ritchie and Ken Thompson at AT&T bell Lab. First, they used to call it as B language then later they made some improvement into it and renamed it as C and its superscript as C++ which was invented by Dr.

What is C in C language?

C is an imperative, procedural language in the ALGOL tradition. It has a static type system. In C, all executable code is contained within subroutines (also called "functions", though not in the sense of functional programming).


1 Answers

If a user presses Ctrl-C while the MessageBox has focus, the message, the MessageBox caption and the MessageBoxButtons labels are copied to the clipboard.

Edit: You could output the messages to a text file and have them email it to you ? to make things easier, you could put the file on their desktop

like image 143
Nasreddine Avatar answered Sep 19 '22 13:09

Nasreddine