New line in string, \n not working

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Assimalyst

    New line in string, \n not working

    Hi,

    I have the following string written in c#:

    string strAddressAll = strAddress1 + ",\n" + strAddress2 + ",\n" +
    strAddress3 + ",\n" + strCountry + ",\n" + strPostcode;

    But it all appears on one line?

    I've also tried adding in :

    + System.Environm ent.NewLine

    but that didn't work either??

    Any ideas what's going on?

    Thanks

  • Vadym Stetsyak

    #2
    Re: New line in string, \n not working

    Where do you display the text? Maybe control is not multiline or smth like
    this.
    Or complete CRLF combination will do?

    FYI CRLF ( carriage return line feed ) - \r\n :)

    --
    Vadym Stetsyak aka Vadmyst

    "Assimalyst " <c_oxtoby@hotma il.com> wrote in message
    news:1126022457 .080557.151420@ g44g2000cwa.goo glegroups.com.. .[color=blue]
    > Hi,
    >
    > I have the following string written in c#:
    >
    > string strAddressAll = strAddress1 + ",\n" + strAddress2 + ",\n" +
    > strAddress3 + ",\n" + strCountry + ",\n" + strPostcode;
    >
    > But it all appears on one line?
    >
    > I've also tried adding in :
    >
    > + System.Environm ent.NewLine
    >
    > but that didn't work either??
    >
    > Any ideas what's going on?
    >
    > Thanks
    >[/color]


    Comment

    • Brendan Grant

      #3
      RE: New line in string, \n not working

      What are you using to display the string strAddressAll?

      If you are using a TextBox, be sure that you have set it’s MultiLine
      property to true.

      Brendan


      "Assimalyst " wrote:
      [color=blue]
      > Hi,
      >
      > I have the following string written in c#:
      >
      > string strAddressAll = strAddress1 + ",\n" + strAddress2 + ",\n" +
      > strAddress3 + ",\n" + strCountry + ",\n" + strPostcode;
      >
      > But it all appears on one line?
      >
      > I've also tried adding in :
      >
      > + System.Environm ent.NewLine
      >
      > but that didn't work either??
      >
      > Any ideas what's going on?
      >
      > Thanks
      >
      >[/color]

      Comment

      • Assimalyst

        #4
        Re: New line in string, \n not working

        I'm using it to set a Label.Text, it dosen't seem to have a multiline
        option.

        Thanks

        Comment

        • Ignacio Machin \( .NET/ C# MVP \)

          #5
          Re: New line in string, \n not working

          Hi,

          Nop, a Label does not have it, depending of the sizse of the label it does
          include the new line.

          You could either use more than one label (not good) or try to justify the
          text with whitespaces (better idea)

          cheers,

          --
          Ignacio Machin,
          ignacio.machin AT dot.state.fl.us
          Florida Department Of Transportation


          "Assimalyst " <c_oxtoby@hotma il.com> wrote in message
          news:1126026557 .127663.54100@g 47g2000cwa.goog legroups.com...[color=blue]
          > I'm using it to set a Label.Text, it dosen't seem to have a multiline
          > option.
          >
          > Thanks
          >[/color]


          Comment

          • Assimalyst

            #6
            Re: New line in string, \n not working

            Thanks, I'll give that a go.

            Comment

            Working...