473,657 Members | 2,513 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Help on help... And stringing things along...

Ok, either I'm doing something wrong or the filters in help are worthless...

I'm trying to format a string... Nothing special, just formatting... like
C++...

How do I do a newline? i.e., assigning a string to a textbox...

txt.Text = "My first line...\n My second line...\n My third line...";
Nov 15 '05 #1
5 1270

"Chuck Bowling" <ch**********@s bcglobal-NO-SPAM.net> wrote in message
news:%2******** ********@TK2MSF TNGP10.phx.gbl. ..
Ok, either I'm doing something wrong or the filters in help are worthless...
I'm trying to format a string... Nothing special, just formatting... like
C++...

How do I do a newline? i.e., assigning a string to a textbox...

txt.Text = "My first line...\n My second line...\n My third line...";

Ok... the newline character works in a string... apparently it just doesn't
get displayed in a textbox control...

Anybody have a clue what's going on? I have the textbox Multiline and
acceptsReturn properties set to True. What am I missing?
Nov 15 '05 #2
Chuck Bowling <ch**********@s bcglobal-NO-SPAM.net> wrote:
How do I do a newline? i.e., assigning a string to a textbox...

txt.Text = "My first line...\n My second line...\n My third line...";

Ok... the newline character works in a string... apparently it just doesn't
get displayed in a textbox control...

Anybody have a clue what's going on? I have the textbox Multiline and
acceptsReturn properties set to True. What am I missing?


You need to use \r\n instead of \n between lines. For instance:

using System;
using System.Windows. Forms;
using System.Drawing;

public class Test : Form
{
Test()
{
Size = new Size(200,200);
TextBox tb = new TextBox();
tb.Size = new Size (150, 150);
tb.Text = "First line\nSecond line\r\nThird line";
tb.Multiline = true;
Controls.Add(tb );
}

static void Main()
{
Application.Run (new Test());
}
}

comes up with

First line Second line
Third line

--
Jon Skeet - <sk***@pobox.co m>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Nov 15 '05 #3
Great. Thanks for your help Jon..
"Jon Skeet [C# MVP]" <sk***@pobox.co m> wrote in message
news:MP******** *************** *@msnews.micros oft.com...
Chuck Bowling <ch**********@s bcglobal-NO-SPAM.net> wrote:
How do I do a newline? i.e., assigning a string to a textbox...

txt.Text = "My first line...\n My second line...\n My third line...";

Ok... the newline character works in a string... apparently it just doesn't get displayed in a textbox control...

Anybody have a clue what's going on? I have the textbox Multiline and
acceptsReturn properties set to True. What am I missing?


You need to use \r\n instead of \n between lines. For instance:

using System;
using System.Windows. Forms;
using System.Drawing;

public class Test : Form
{
Test()
{
Size = new Size(200,200);
TextBox tb = new TextBox();
tb.Size = new Size (150, 150);
tb.Text = "First line\nSecond line\r\nThird line";
tb.Multiline = true;
Controls.Add(tb );
}

static void Main()
{
Application.Run (new Test());
}
}

comes up with

First line Second line
Third line

--
Jon Skeet - <sk***@pobox.co m>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too

Nov 15 '05 #4
There is an
Environment.New Line Property

Which, in Windows, is equivalent to "\r\n"
It may be different on other platforms, so if you plan on using other
platforms, you may want to use this property instead.

Chris R.

"Chuck Bowling" <ch**********@s bcglobal-NO-SPAM.net> wrote in message
news:#v******** ******@TK2MSFTN GP10.phx.gbl...
Ok, either I'm doing something wrong or the filters in help are worthless...
I'm trying to format a string... Nothing special, just formatting... like
C++...

How do I do a newline? i.e., assigning a string to a textbox...

txt.Text = "My first line...\n My second line...\n My third line...";

Nov 15 '05 #5
Ok. Thanks Chris...

"Chris R" <so*****@hotmai l.com> wrote in message
news:%2******** ********@TK2MSF TNGP10.phx.gbl. ..
There is an
Environment.New Line Property

Which, in Windows, is equivalent to "\r\n"
It may be different on other platforms, so if you plan on using other
platforms, you may want to use this property instead.

Chris R.

"Chuck Bowling" <ch**********@s bcglobal-NO-SPAM.net> wrote in message
news:#v******** ******@TK2MSFTN GP10.phx.gbl...
Ok, either I'm doing something wrong or the filters in help are

worthless...

I'm trying to format a string... Nothing special, just formatting... like C++...

How do I do a newline? i.e., assigning a string to a textbox...

txt.Text = "My first line...\n My second line...\n My third line...";


Nov 15 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
1785
by: James Walker | last post by:
Can some one help I get an error of 'checkIndate' is null or not an object can someone please help. I can't work out why Thanks in advance James <form> <td height="24" colspan="7" valign="top"><form name="booknow"><select
8
2977
by: Johnny | last post by:
I need to determine whether a text box contains a value that does not convert to a decimal. If the value does not convert to a decimal, I want to throw a MessageBox to have the user correct the value in the text box. I have the following code but when the user enters a decimal value the Regex.IsMatch catches it (ex. 250.50 should be allowed, but 250.50.0 should not). My code is as follows: if( ! Regex.IsMatch( tboxQtyCounted.Text,...
3
1289
by: arthur-e | last post by:
Thanks in advance!! I've looked at fConcatFld but that doesn't seem to be what i'm looking for or I just can't figure it out. I'm trying to have a button select records based on two combo boxes - one holding a number and one text. Floor(combo18) is a floor number and site(combo20) is a building name Private Sub Command22_Click() Dim strSQL As String
11
1596
by: dhnriverside | last post by:
Hi peeps Ok, so I thought I'd have a go at making a console app in VS2k5... I haven't written any windows apps for years, let alone dos apps (been web programming) and I've hit a dumb error... "An object reference is required for the nonstatic field, method or property " This is occuring in my main function...
3
1662
by: ESmith | last post by:
I have multi-page form where I pass an object between pages as follows: On each page: // What page to go to next private void btnContinue_Click(object sender, System.EventArgs e) { if (Page.IsValid) { MyXferObj obj = new MyXferObj();
1
3705
by: Rahul | last post by:
Hi Everybody I have some problem in my script. please help me. This is script file. I have one *.inq file. I want run this script in XML files. But this script errors shows . If u want i am attach this script files and inq files. I cant understand this error. Please suggest me. You can talk with my yahoo id b_sahoo1@yahoo.com. Now i am online. Plz....Plz..Plz...
6
1678
by: JOSII | last post by:
Getting a string of boolean value into and out of the registry is no problem. Here's the problem: Although you can place an object into the registry and retreive it, I need to place an ArrayList object with 10 string items into the registry and retreive them later. I tried this: key.SetValue("lstNSXitems", lstNSX.Items) where "lstNSXitems" is the name of the subkey, and lstNSX.Items is the
0
5558
by: gunimpi | last post by:
http://www.vbforums.com/showthread.php?p=2745431#post2745431 ******************************************************** VB6 OR VBA & Webbrowser DOM Tiny $50 Mini Project Programmer help wanted ******************************************************** For this teeny job, please refer to: http://feeds.reddit.com/feed/8fu/?o=25
2
2010
by: abdiphp | last post by:
Hi every one, I need help to get the this going, Itried whatever I can but could not get the right xpath to this xml I need to get the value of this node (IMAGE_FILE) and this is not working /row/ARTICLE/RELATE/IMAGE_FILE/IMAGE_PATH
0
8413
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8842
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8740
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
7352
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6176
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5642
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4173
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
2742
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1970
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.