PC Review
Forums
Newsgroups
Microsoft DotNet
Microsoft Dot NET Framework Forms
Stringy bits of rubbish.
Forums
Newsgroups
Microsoft DotNet
Microsoft Dot NET Framework Forms
Stringy bits of rubbish.
![]() |
Stringy bits of rubbish. |
|
|
Thread Tools | Rate Thread |
|
|
#1 |
|
Guest
Posts: n/a
|
I am starting to really hate managed C++. Ok. I am trying to add a newline character to a std::string and it won't do it. Whenever you put in << endl or + endl it wont compile because the managed bit is ****. If I was to put in /n or /r or /n/r and other variations it kinda works. As in, if I display the string in a MessageBox it works fine. However, a text box does not work. All I get is little squares. It's as if you open a text file that works fine in Linux but the fonts are out in Windows. I am going insane and the MSDN is rubbish. Cheers -- www.integrated-dev-sol.co.uk Remove 123 from email address to reply. Anti spam and virus measure. |
|
|
|
#2 |
|
Guest
Posts: n/a
|
John Swan <j.a.swan123@ntlworld.com> wrote:
> I am starting to really hate managed C++. > > Ok. > > I am trying to add a newline character to a std::string and it won't do it. > > Whenever you put in << endl or + endl it wont compile because the managed > bit is ****. I'm not familiar with managed C++, but I suspect there are plenty of ways to do this elegantly. Using obscenities about the language doesn't help, and it's likely to make people reluctant to try to help you. > If I was to put in /n or /r or /n/r and other variations it kinda works. As > in, if I display the string in a MessageBox it works fine. > > However, a text box does not work. > > All I get is little squares. It's as if you open a text file that works fine > in Linux but the fonts are out in Windows. It sounds like you're getting it into the string just fine, but haven't used the correct variation ("\r\n") for the text box. Also, have you set the Multiline property of the TextBox to true? -- Jon Skeet - <skeet@pobox.com> http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet If replying to the group, please do not mail me too |
|
|
|
#3 |
|
Guest
Posts: n/a
|
> I'm not familiar with managed C++, but I suspect there are plenty of
> ways to do this elegantly. Using obscenities about the language doesn't > help, and it's likely to make people reluctant to try to help you. Please forgive the profanity. Instead use it as a measure of how frustrating the managed bit is. > > If I was to put in /n or /r or /n/r and other variations it kinda works. As > > in, if I display the string in a MessageBox it works fine. > It sounds like you're getting it into the string just fine, but haven't > used the correct variation ("\r\n") for the text box. Also, have you > set the Multiline property of the TextBox to true? Yeah it does go into the string. Displaying that string in a messagebox does result in it being displayed correctly. It just wont display correctly in the text box. Multiline is also enabled. "Jon Skeet [C# MVP]" <skeet@pobox.com> wrote in message news:MPG.1e08d5a86cc566d198cb2b@msnews.microsoft.com... > John Swan <j.a.swan123@ntlworld.com> wrote: > > I am starting to really hate managed C++. > > > > Ok. > > > > I am trying to add a newline character to a std::string and it won't do it. > > > > Whenever you put in << endl or + endl it wont compile because the managed > > bit is ****. > > I'm not familiar with managed C++, but I suspect there are plenty of > ways to do this elegantly. Using obscenities about the language doesn't > help, and it's likely to make people reluctant to try to help you. > > > If I was to put in /n or /r or /n/r and other variations it kinda works. As > > in, if I display the string in a MessageBox it works fine. > > > > However, a text box does not work. > > > > All I get is little squares. It's as if you open a text file that works fine > > in Linux but the fonts are out in Windows. > > It sounds like you're getting it into the string just fine, but haven't > used the correct variation ("\r\n") for the text box. Also, have you > set the Multiline property of the TextBox to true? > > -- > Jon Skeet - <skeet@pobox.com> > http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet > If replying to the group, please do not mail me too |
|
|
|
#4 |
|
Guest
Posts: n/a
|
John Swan <j.a.swan123@ntlworld.com> wrote:
> > It sounds like you're getting it into the string just fine, but haven't > > used the correct variation ("\r\n") for the text box. Also, have you > > set the Multiline property of the TextBox to true? > > Yeah it does go into the string. Displaying that string in a messagebox does > result in it being displayed correctly. > It just wont display correctly in the text box. > Multiline is also enabled. Could you post a short but complete program which demonstrates the problem? See http://www.pobox.com/~skeet/csharp/complete.html for details of what I mean by that. Here's an example (in C#) which demonstrates it working. You might want to adapt it to C++ to test things that way: using System; using System.Windows.Forms; using System.Drawing; class Test { static void Main() { Form f = new Form(); f.Size = new Size (300, 300); TextBox tb = new TextBox(); tb.Size = new Size (290, 290); tb.Multiline = true; tb.Text = "Hello\r\nThere"; f.Controls.Add(tb); Application.Run(f); } } -- Jon Skeet - <skeet@pobox.com> http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet If replying to the group, please do not mail me too |
|
|
|
#5 |
|
Guest
Posts: n/a
|
Whey!!!!
Sorry, I missed a large part of the code that had \n\r! Changed that too \r\n and it worked. I am really not sure why it would do one thing on one control and not the other. I am sorry for the outburst. But coming from a non managed C++ to this is weird. Everything is just designed to be difficult in my opinion. Anyway. Thanks. John "Jon Skeet [C# MVP]" <skeet@pobox.com> wrote in message news:MPG.1e0919e372e5c84998cb33@msnews.microsoft.com... > John Swan <j.a.swan123@ntlworld.com> wrote: > > > It sounds like you're getting it into the string just fine, but haven't > > > used the correct variation ("\r\n") for the text box. Also, have you > > > set the Multiline property of the TextBox to true? > > > > Yeah it does go into the string. Displaying that string in a messagebox does > > result in it being displayed correctly. > > It just wont display correctly in the text box. > > Multiline is also enabled. > > Could you post a short but complete program which demonstrates the > problem? > > See http://www.pobox.com/~skeet/csharp/complete.html for details of > what I mean by that. > > Here's an example (in C#) which demonstrates it working. You might want > to adapt it to C++ to test things that way: > > using System; > using System.Windows.Forms; > using System.Drawing; > > class Test > { > static void Main() > { > Form f = new Form(); > f.Size = new Size (300, 300); > > TextBox tb = new TextBox(); > tb.Size = new Size (290, 290); > tb.Multiline = true; > tb.Text = "Hello\r\nThere"; > > f.Controls.Add(tb); > Application.Run(f); > } > } > > -- > Jon Skeet - <skeet@pobox.com> > http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet > If replying to the group, please do not mail me too |
|
|
|
#6 |
|
Guest
Posts: n/a
|
John Swan <j.a.swan123@ntlworld.com> wrote:
> Whey!!!! > > Sorry, I missed a large part of the code that had \n\r! Changed that too > \r\n and it worked. > > I am really not sure why it would do one thing on one control and not the > other. > I am sorry for the outburst. > But coming from a non managed C++ to this is weird. Everything is just > designed to be difficult in my opinion. I'm sure when you get used to it you'll love it. When I have to go back to unmanaged code every so often I'm amazed we ever managed to accomplish what we did back in the bad old days... -- Jon Skeet - <skeet@pobox.com> http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet If replying to the group, please do not mail me too |
|
![]() |
|
| Thread Tools | |
| Rate This Thread | |
|
|

Main Page 

