简体   繁体   English

C#MessageBox不再显示整个文本字符串

[英]C# MessageBox doesn't display the whole string of text anymore

I am trying to display a simple message, which I have done probably thousands of times in the past, and NOW... The full string of text is NOT being displayed in the MessageBox. 我试图显示一条简单的消息,我过去已经做过几千次了,现在......消息框中没有显示完整的文本字符串。 I'm not doing anything differently, so I don't see the problem. 我没有做任何不同的事情,所以我没有看到问题。 Here's my code: 这是我的代码:

if (MessageBox.Show("The text in this file has changed. Do you want to save changes?",
    "TextEditor - Confirmation", MessageBoxButtons.YesNo, MessageBoxIcon.Hand, MessageBoxDefaultButton.Button1) == DialogResult.Yes)
{ //Do stuff 
} else { 
// Do stuff }

Now, when the messagebox is displayed, the only text that is visible is this: 现在,当显示消息框时,唯一可见的文本是:

The text in this file has changed. 此文件中的文本已更改。

NOTE: The Yes/No buttons are visible, and the messagebox looks normal, it doesn't look broken or anything, so I have no idea why I can't display a simple dam question in there anymore!?... Does anybody know about this? 注意:是/否按钮是可见的,消息框看起来正常,它看起来不会破碎或任何东西,所以我不知道为什么我不能在那里显示一个简单的大坝问题了!?...有没有人知道这个吗? Have you experienced this before? 你以前经历过这个吗?

Thanks 谢谢

OK, THIS IS WIERD... (EDITED) 好的,这是更好...(已编辑)

I have just changed the text for the above messagebox text and now it displays the following: 我刚刚更改了上述消息框文本的文本,现在它显示以下内容:

The text in this file has changed. 此文件中的文本已更改。 Do you wa 你哇

But the most important part of the question is still not being displayed... 但问题中最重要的部分仍未显示......

Couple of things to try: 有几件事要尝试:
1) If running the debug version, try compiling and running the release version 1)如果运行调试版本,请尝试编译并运行发行版本
2) Try creating a whole new project and copying the code to the new project and run it (could be a project setting was changed, then you could diff the files) 2)尝试创建一个全新的项目并将代码复制到新项目并运行它(可能是项目设置已更改,然后您可以区分文件)
3) Try disabling any anti-virus software you have. 3)尝试禁用您拥有的任何防病毒软件。

The space between "changed." “改变了”之间的空间。 and "Do" wouldn't be some weird character (say NULL), would it? 并且“Do”不会是一些奇怪的角色(比如说NULL),不是吗? Try to delete the whole text and then type it again by hand. 尝试删除整个文本,然后手动再次键入。


Hmm... just remembered some weird old bug with McAffee antivirus and .NET whereupon the whole contents of messageboxes would disappear. 嗯......只记得一些奇怪的老虫与McAffee杀毒软件和.NET,消息盒的全部内容都会消失。 This was however more than 5 years ago... 然而这已经超过5年了......

Maybe try updating your PC? 也许尝试更新你的电脑? And - you wouldn't happen to be running McAffee, would you? 并且 - 你不会碰巧运行McAffee,是吗? :) :)


Idea No. 3: Send us your compiled .EXE and the source files? 想法3:将您编译的.EXE和源文件发送给我们?
Idea No. 4: Compile it, then rip it open with Reflector and check how it has been compiled. 想法4:编译它,然后用Reflector打开它并检查它是如何编译的。 Compilers have bugs too... 编译器也有bug ...

have you tried - just to be sure - to escape the whole string by prefixing it with a @-sign? 你试过 - 只是为了确定 - 通过在@ -sign前面添加前缀来逃避整个字符串?

like so: 像这样:


if (MessageBox.Show(@"The text in this file has changed. Do you want to save changes?",
    @"TextEditor - Confirmation", MessageBoxButtons.YesNo, MessageBoxIcon.Hand, MessageBoxDefaultButton.Button1) == DialogResult.Yes)
{ //Do stuff 
} else { 
// Do stuff }

Its something odd/stupid - its time to act back by being stupid 它奇怪/愚蠢的东西 - 它是时候通过愚蠢来回击

First question - are all of your message boxes affected? 第一个问题 - 您的所有信息框都受到了影响吗? If not then this case has something wrong with it. 如果没有,那么这个案子就有问题了。 If they are all affected then ... well I don't know what to suggest really. 如果他们都受到影响那么......我真的不知道该建议什么。 More coffee? 更多咖啡?

Best thing to do is to reduce the problem down to the smallest possible. 最好的办法是尽可能减少问题。 Create a new message box and only enter your current text (copy and paste it). 创建一个新消息框,仅输入当前文本(复制并粘贴)。 Dont set any of the other parameters and take it out of the if statement 不要设置任何其他参数并将其从if语句中取出

If that works, then the problem is with the parameters - slowly add the parameters until it breaks 如果可行,那么问题在于参数 - 慢慢添加参数直到它中断

If it doesnt then the problem is with the text - delete the text and retype it - there may be a strange character there - eg has the text been near MS Word... - if that works, then you are golden - otherwise, delete word by word until it starts working 如果它没有那么问题是文本 - 删除文本并重新键入 - 那里可能有一个奇怪的字符 - 例如文本已经接近MS Word ... - 如果有效,那么你是金色的 - 否则,删除逐字逐句,直到它开始工作

I reckon you'll find out it something really stupid 我估计你会发现它真的很蠢

Did you try to put your text in a variable juste to see if it work? 您是否尝试将文本放在变量juste中以查看它是否有效?

string message = @"The text in this file has changed. Do you want to save changes?";
string title = "TextEditor - Confirmation";

if (MessageBox.Show,(message, title, MessageBoxButtons.YesNo, MessageBoxIcon.Hand, MessageBoxDefaultButton.Button1) == DialogResult.Yes){ //Do stuff } else { // Do stuff }

I've tried it too and it seems to work fine. 我也尝试了它似乎工作正常。 Maybe check the regional/language settings on the machine your running it on? 也许检查运行它的机器上的区域/语言设置?

There's no set size for message boxes in the form.Designer.cs is there? form.Designer.cs中没有设置消息框的大小?

Have you tried creating another solution with 1 form and the following code - btw works form me vs2008 winXP en-gb lang 您是否尝试使用1表单和以下代码创建另一个解决方案 - 顺便说一下我的作品vs2008 winXP en-gb lang

using System;

using System.ComponentModel;

using System.Drawing;

using System.Text;

using System.Windows.Forms;

namespace WindowsFormsApplication1
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
            if (MessageBox.Show("The text in this file has changed. Do you want to save changes?", "TextEditor - Confirmation", MessageBoxButtons.YesNo, MessageBoxIcon.Hand, MessageBoxDefaultButton.Button1) == DialogResult.Yes)
            {
                MessageBox.Show("yes");
            }
            else
            {
                MessageBox.Show("no");
            }


        }
    }
}

您可以在“更改”后尝试换行吗?

I have just solved this problem. 我刚刚解决了这个问题。 I am using Windows XP Home Edition and am also using Stardock's WindowBlinds to pretty-up the 500-year old WindowsXP interface. 我正在使用Windows XP Home Edition,并且还使用Stardock的WindowBlinds来完善具有500年历史的WindowsXP界面。 This has never caused any problems in the past, I have been using WindowBlinds for years, and also doing C# stuff for about a year and a half, and this is the first time that WindowBlinds has caused any problems what so ever. 这在过去从未引起过任何问题,我多年来一直在使用WindowBlinds,并且还使用C#的东西大约一年半,这是WindowBlinds第一次引起任何问题。

The reason why only part of the text was showing in the MessageBox still ramins a mystery, BUT as soon as I decided to try and Close WindowBlinds and apply the standard XP theme again... All MessageBox's work properly in C#. 只有部分文本在MessageBox中显示的原因仍然是一个谜,但是当我决定尝试关闭WindowBlinds并再次应用标准XP主题时...所有MessageBox在C#中正常工作。


Thank you ALL for your good suggestions they are very much appreciated. 谢谢大家的好建议,我们非常感谢。 :o) :O)

Jason Pezzimenti Jason Pezzimenti

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM