Richtextbox new line problem!

Hello,

when I'm using a RichTextbox and I apply a "sestem.environnement.newline(), then not a new line is taken, but two new lines. Can you disable this

tnx in advance


Answer this question

Richtextbox new line problem!

  • Bissy

    Bold b = new Bold();
    b.Text = "some bold text";

    Run r = new Run("some normal text");

    LineBreak lb = new LineBreak();

    Paragraph p = new Paragraph();
    p.Inlines.Add(r);
    p.Inlines.Add(lb);
    p.Inlines.Add(b);

    txtGPSUnitProperties.Document.Blocks.Add(p);


  • Techno_Dex

    Linebreak doesn't seem to work

    //Declaration of the linebreak
    LineBreak lb = new LineBreak();

    //piece of code creation of the block
    if (_nearbyLocations[0].Address != null && _nearbyLocations[0].Address.PrimaryCity.ToString()!="") {
    Run rLocCity = new Run("\t" + _nearbyLocations[0].Address.PrimaryCity.ToString());
    Run rLocPostal = new Run(", " + _nearbyLocations[0].Address.PostalCode.ToString());
    Run rLocSubdiv = new Run("\t" + _nearbyLocations[0].Address.Subdivision.ToString());
    Run rLocCountry = new Run("\t" + _nearbyLocations[0].Address.CountryRegion.ToString());
    p.Inlines.Add(rLocCity);
    p.Inlines.Add(rLocPostal);
    p.Inlines.Add(lb);
    p.Inlines.Add(rLocSubdiv);
    p.Inlines.Add(lb);
    p.Inlines.Add(rLocCountry);
    p.Inlines.Add(lb);
    }
    else {
    Run rNoAdress = new Run("\tNo nearby location found!");
    p.Inlines.Add(rNoAdress);
    p.Inlines.Add(lb);
    }

    // Text from the window when executed
    GpsUnit ID:1GpsUnit Code:sdfgsdfgsdfgsdfgGpsUnit Latitude:40° 2' 40''GpsUnit Longitude:19° 55' 43''Location: No nearby location found!----------------------------------------------------------------------------GpsUnit Brand:WhereNet
    GpsUnit Description:A Wherenet GPSUnit

  • fly_eye

    Its not clear how you are applying "system.Environment.NewLine" in RichTextBox.

    If its in code, can you send the repro code for your scenario



  • Varsha Sharma

    Do not use the same LineBreak in several places, use distinct ones.
    So instead of
    p.Inlines.Add(lb);
    use
    p.Inlines.Add(new LineBreak());


  • St3veM

    Hello Siri,

    I solved it by using a normal textbox. The intention was to set some text bold, but this didn't work out as well as I tought. Following I've pasted some code in what manner I applied System.Environment.NewLine...

    this.txtGPSUnitProperties.Text += "GpsUnit ID: "
    + this._myPushpinListIdea.getPushPin.PinID
    + System.Environment.NewLine
    + "GpsUnit Code: " + this._myPushpinListIdea.getPushPinCode
    + System.Environment.NewLine
    + "GpsUnit Latitude: "
    + convertToDMS(this._myPushpinListIdea.getPushPin.LatLong.Latitude)
    + System.Environment.NewLine
    + "GpsUnit Longitude: "
    + convertToDMS(this._myPushpinListIdea.getPushPin.LatLong.Longitude)
    + System.Environment.NewLine
    + "Location: ";

    I wanted to set the underlined text into bold, but I didn't find any way to accomplish this. If there is a way, please tell me so. Oh, and when I used this code, every newline took 2 new lines. Don't know why

  • Ahmed Sajwani

    Thanks man

  • Richtextbox new line problem!