Link to home
Start Free TrialLog in
Avatar of vbMarkO
vbMarkO

asked on

What am I missing? simple RTB selection

I want this

John Doe
  Member: Yes
  HomePhone: None Available
  Cell Phone: 731-555-1234
  Address: 123 Some Street
  City: Milan
  State: TN
  Notes:  A simple description can go here or note

NOTE  the indent but what I am getting is what you see above on the first loop but as it lays in the rest of the contacts in the xml it indents them all like this

John Doe
  Member: Yes
  HomePhone: None Available
  Cell Phone: 731-555-1234
  Address: 123 Some Street
  City: Milan
  State: TN
  Notes:  A simple description can go here or note

  Jane Doe
  Member: Yes
  HomePhone: 731-234-6587
  Cell Phone: 731-555-1234
  Address: 765 Another Street
  City: Milan
  State: TN
  Notes:  A simple description can go here or note

NOTE Jane Doe should not be indented it should be like John Doe
Here is my code

Dim doc = XDocument.Load(myPath & "testXML.xml")



        For Each myCon In doc...<Contact>
            rtb1.SelectionStart = rtb1.TextLength
            Dim curFont As Font = rtb1.SelectionFont
            rtb1.SelectionFont = New Font(rtb1.Font, FontStyle.Bold)
            rtb1.AppendText(myCon.@Fname & " " & myCon.@Lname & vbNewLine) ' ////

            rtb1.SelectionFont = curFont
            rtb1.SelectionIndent = 8
            rtb1.AppendText("Member: " & myCon.@Member & vbNewLine)
            rtb1.AppendText("HomePhone: " & myCon.<HomePhone>.Value & vbNewLine)
            rtb1.AppendText("Cell Phone: " & myCon.<CellPhone>.Value & vbNewLine)
            rtb1.AppendText("Address: " & myCon.<Address>.Value & vbNewLine)
            rtb1.AppendText("City: " & myCon.<City>.Value & vbNewLine)
            rtb1.AppendText("State: " & myCon.<State>.Value & vbNewLine)
            rtb1.AppendText("Notes: " & myCon.<Notes>.Value & vbNewLine & vbNewLine)
        Next

Open in new window

Avatar of vbMarkO
vbMarkO

ASKER

I was able to do it this way just playing around with it but it seems ... off

Is it right or better way of doing this
For Each myCon In doc...<Contact>
            rtb1.SelectionStart = rtb1.TextLength
            Dim curFont As Font = rtb1.SelectionFont
            rtb1.SelectionFont = New Font(rtb1.Font, FontStyle.Bold)
            rtb1.AppendText(myCon.@Fname & " " & myCon.@Lname & vbNewLine) ' ////

            rtb1.SelectionFont = curFont
            rtb1.SelectionIndent = 8
            rtb1.AppendText("Member: " & myCon.@Member & vbNewLine)
            rtb1.AppendText("HomePhone: " & myCon.<HomePhone>.Value & vbNewLine)
            rtb1.AppendText("Cell Phone: " & myCon.<CellPhone>.Value & vbNewLine)
            rtb1.AppendText("Address: " & myCon.<Address>.Value & vbNewLine)
            rtb1.AppendText("City: " & myCon.<City>.Value & vbNewLine)
            rtb1.AppendText("State: " & myCon.<State>.Value & vbNewLine)
            rtb1.AppendText("Notes: " & myCon.<Notes>.Value & vbNewLine & vbNewLine)
            rtb1.SelectionFont = curFont
            rtb1.SelectionIndent = 0
        Next

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of Mike Tomlinson
Mike Tomlinson
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of vbMarkO

ASKER

Right on the money very understandable too

Thank you Idle_Mind you da man!!!