jay_t55
jay_t55

Reputation: 11652

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

Upvotes: 3

Views: 6566

Answers (9)

jay_t55
jay_t55

Reputation: 11652

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

Upvotes: 0

Vilx-
Vilx-

Reputation: 106920

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

Upvotes: 2

Chris Gill
Chris Gill

Reputation: 2928

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

Upvotes: 2

Corey
Corey

Reputation: 1195

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

Upvotes: 1

littlegeek
littlegeek

Reputation:

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");
            }


        }
    }
}

Upvotes: 1

Polo
Polo

Reputation: 1820

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 }

Upvotes: 2

Tikeb
Tikeb

Reputation: 1068

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?

Upvotes: 1

SwDevMan81
SwDevMan81

Reputation: 49988

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.

Upvotes: 3

360Airwalk
360Airwalk

Reputation: 2207

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 }

Upvotes: 2

Related Questions