Results 1 to 3 of 3

Thread: Function and Listview Values

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Feb 2009
    Location
    Scotland
    Posts
    417

    Function and Listview Values

    Hi Guys,

    I can't seem to see a solution to this problem, i have this function:

    vb.net Code:
    1. Function functionDisplayLoggedInAccountData(ByVal HTML As String)
    2.  
    3.         Dim testStr As String = HTML
    4.         Dim startAt As Integer = 0
    5.         Dim lastIndex As Integer = 0
    6.  
    7.         Do
    8.  
    9.             lastIndex = startAt
    10.  
    11.             '// The first apttern we are looking for
    12.             Dim rx As New Regex("<tr bgcolor=""lightgreen"">")
    13.  
    14.             startAt = rx.Match(testStr, startAt).Index + 28
    15.  
    16.             If startAt < lastIndex Then Exit Do
    17.  
    18.             '// The second pattern we are looking for
    19.             rx = New Regex("(?<=<td nowrap>).*(?=</td>)")
    20.  
    21.             '// The third pattern we are looking for
    22.             Dim rxNew = New Regex("(?<=<td>).*(?=</td>)")
    23.  
    24.             Dim postIDNumber As Integer = rxNew.Matches(testStr, startAt).Item(0).Value
    25.  
    26.             With formMain.mainListView.Items.Add(rx.Matches(testStr, startAt).Item(0).Value)
    27.                 .SubItems.Add(rx.Matches(testStr, startAt).Item(1).Value)
    28.                 .SubItems.Add(rx.Matches(testStr, startAt).Item(2).Value)
    29.  
    30.                 '// Do some string manipulation
    31.                 Dim newString As String = rx.Matches(testStr, startAt).Item(3).Value.Replace("<a href=""/post/shwpst?pii=" & (postIDNumber) & "&amp;db=lv"">", "")
    32.                 Dim finalString As String = newString.Replace("</a>", "")
    33.  
    34.                 .SubItems.Add(finalString)
    35.  
    36.                 '// Colour the background
    37.                 .BackColor = Color.PaleGreen
    38.  
    39.             End With
    40.  
    41.         Loop
    42.  
    43.         Return True
    44.  
    45.     End Function

    Which works well, but there are 2 more html fields called:

    td bgcolor="lightblue"
    td bgcolor="lightgrey"


    In my code i just look for the bgcolor="lightgreen" field, is there a way i can get all colours and display the listview background colour accordingly?

    thanks guys

    Graham

  2. #2
    eXtreme Programmer .paul.'s Avatar
    Join Date
    May 2007
    Location
    Chelmsford UK
    Posts
    26,422

    Re: Function and Listview Values

    you can choose a color by a string name:

    vb Code:
    1. Color.FromName("Color.PaleGreen")

  3. #3

    Thread Starter
    Hyperactive Member
    Join Date
    Feb 2009
    Location
    Scotland
    Posts
    417

    Re: Function and Listview Values

    Hi Paul,

    what i was trying to do was look for all the bgcolor tags in the html, currently i just look for Dim rx As New Regex("<tr bgcolor=""lightgreen"">") so when i find the green values, i colour the background green, when i retrieve all the blue values i turn the listview blue etc

    thanks mate

    Graham

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width