问题描述
我一直在寻找对谷歌现在的计算器2小时。必须有什么我只是简单地眺望。有一个简单的方法,使在一个消息文本选择?截至目前,当我调用MessageBox.Show()我不能复制显示的文本。为什么不?如何将我设置文本被复制能够
我的代码:
//捕获所有异常
赶上(异常前)
{
MessageBox.Show(ex.Message);
//抛出;
}
我希望能够选择出来,这样用户错误信息可以将其发送给我,我可以解决他们的问题。 。任何帮助是极大的赞赏。
编辑:不能使用CRTL-C的方法。我的用户是无法把握的概念。需要鼠标突出显示并右键单击选择选项。 !谢谢
编辑:供参考我落得正在使用的答案的混合物做。我创建了一个弹出窗口,用一个按钮,在按钮动作我复制到剪贴板。它并不完美,但与正确的标签,它运作良好,足够了。谢谢大家的建议!
//捕获所有异常
赶上(异常前)
{
//MessageBox.Show(ex.Message);
MessageBoxButtons按钮= MessageBoxButtons.OK;
DialogResult的结果;
//显示消息框。
结果= MessageBox.Show(ex.Message +\\\
\\\
Click OK按钮复制到剪贴板,错误按钮);
如果(结果== System.Windows.Forms.DialogResult.OK)
{
Clipboard.SetText(ex.Message);
//抛出;
}
}
如果用户按按Ctrl-C
而在MessageBox具有焦点,该消息,该消息框标题和MessageBoxButtons标签复制到剪贴板。
修改:您可以输出信息到一个文本文件,并让他们通过电子邮件发送给你吗?为方便起见,你可以把文件在桌面
上
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;
}
}
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
这篇关于从messagebox.show弹出C#中选择文本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!