views:

706

answers:

9

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

+3  A: 

The space between "changed." and "Do" wouldn't be some weird character (say NULL), would it? 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. This was however more than 5 years ago...

Maybe try updating your PC? And - you wouldn't happen to be running McAffee, would you? :)


Idea No. 3: Send us your compiled .EXE and the source files?
Idea No. 4: Compile it, then rip it open with Reflector and check how it has been compiled. Compilers have bugs too...

Vilx-
I've tried writing it by hand many times. I've even tried changing the wording, and it still just cuts off the last parts of any sentence.
baeltazor
...and no it doesn't say NULL anywhere. This is oober wierd.
baeltazor
i'm not using mcaffee... i'm using Eset Smart Security
baeltazor
+2  A: 

have you tried - just to be sure - to escape the whole string by prefixing it with a @-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 }
360Airwalk
thanks for the reply - I just tried that, and it still only displays:The text in this file has changed. Do you wa...Thats after adding the @ to the beginning of both strings..
baeltazor
+3  A: 

Couple of things to try:
1) If running the debug version, try compiling and running the release version
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)
3) Try disabling any anti-virus software you have.

SwDevMan81
thanks for the suggestions, i just finished trying them and so far no luck at all. :(
baeltazor
How about trying the modal version: MessageBox.Show(mainForm, "The text in this file has changed. Do you want to save changes?", "TextEditor - Confirmation", MessageBoxButtons.YesNo, MessageBoxIcon.Hand, MessageBoxDefaultButton.Button1)
SwDevMan81
hi thanks for that but it comes up with a red squigly line underneith the mainForm part
baeltazor
+1  A: 

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?

Tikeb
Thanks. I've checked and those settings are fine.
baeltazor
+2  A: 

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 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 - e.g. has the text been near MS Word... - if that works, then you are golden - otherwise, delete word by word until it starts working

I reckon you'll find out it something really stupid

Chris Gill
Fixed a typo and upvoted for a good suggestion!
Vilx-
Thank you so much for the suggestions, though I still have the problem. I've even tried re-writing the whole messagebox/if statement from scratch and it has made no difference at all.
baeltazor
+1 for suggesting Coffee during this difficult time
baeltazor
+1  A: 

Did you try to put your text in a variable juste to see if it work?

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 }
Polo
Yes sir I have indeed, still has the same problems
baeltazor
+1  A: 

Have you tried creating another solution with 1 form and the following code - btw works form me 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");
            }


        }
    }
}
Thank you for this. I pasted your code and did not make any changes to it. However, the problem still happens. But the if statement works correctly, if i click yes it pops up a message saying yes, and the same happens for the no button.
baeltazor
+1  A: 

Could you possibly try a newline \n after "changed"?

Corey
Thanks for the suggestion, I have already tried this with no luck. I've even tried using it with no new line at all and still doesn't work properly
baeltazor
A: 

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

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#.


Thank you ALL for your good suggestions they are very much appreciated. :o)

Jason Pezzimenti

baeltazor