SelectionAlignment = TextAlignments.Left

  1. 2 weeks ago

    I am trying to save a TextArea using StyledText.RTFData but while it looks okay in the TextArea, it is not saving the left text alignment but picks up the center alignment from the title. Examining the data I can see that the \ql is missing in the RTFData. I am using Narrative.SelectionAlignment = TextAlignments.Left to format the data in the TextArea.

    Is there something I should do differently?

    Var data As RowSet = App.GetData("Select * from Narratives where Lower(GrpName) = "+GrpName.Lowercase.DoubleQuote)
    If data <> Nil And Not data.AfterLastRow Then
      data.EditRow
      data.Column("Narrative").StringValue=Narrative.StyledText.RTFData
      data.SaveRow
      data.Close
      data = Nil
    Else
      Var row As New DatabaseRow
      row.Column("GrpName").StringValue = GrpName
      row.Column("Narrative").StringValue = Narrative.StyledText.RTFData
      App.db.AddRow("Narratives", row)
    End If
  2. Jason P

    May 21 Xojo Inc, Forum Moderators Texas

    I don't see any obvious problem in your code. Do you know if you can reproduce this in a test project?

  3. Thank you for the reply. Found a workaround by storing the alignments in the database. All I can tell you is that the \ql was missing in the rtfdata.

    Var align(-1) As String
    Var num As Integer = Narrative.StyledText.ParagraphCount
    For i As Integer = 1 To num
      
    Narrative.SelectionStart = Narrative.StyledText.Paragraph(i).StartPosition
    Narrative.SelectionLength = Narrative.StyledText.Paragraph(i).Length
      
      Select Case Narrative.SelectionAlignment
      Case TextAlignments.Left
        align.AddRow("L")
      Case TextAlignments.Center
        align.AddRow("C")
      Case TextAlignments.Right
        align.AddRow("R")
      End Select
      
    Next
    
    Var data As RowSet = App.GetData("Select * from Narratives where Lower(GrpName) = "+GrpName.Lowercase.DoubleQuote)
    If data <> Nil And Not data.AfterLastRow Then
      data.EditRow
      data.Column("ColumnAlignments").StringValue=String.FromArray(align,"~")
      data.Column("Narrative").StringValue=Narrative.StyledText.RTFData
      data.SaveRow
      data.Close
      data = Nil
    Else
      Var row As New DatabaseRow
      row.Column("GrpName").StringValue = GrpName
      row.Column("ColumnAlignments").StringValue=String.FromArray(align,"~")
      row.Column("Narrative").StringValue = Narrative.StyledText.RTFData
      App.db.AddRow("Narratives", row)
    End If
  4. Jason P

    May 21 Xojo Inc, Forum Moderators Texas

    Nice workaround! Glad to hear that it's working for you now.

or Sign Up to reply!