Adblock breaks this site

help with ListView please!

Discussion in 'Programming General' started by hmm, Jun 12, 2007.

  1. hmm

    hmm Active Member

    Joined:
    Jan 21, 2007
    Posts:
    181
    Referrals:
    2
    Sythe Gold:
    5
    help with ListView please!

    [​IMG]
    http://i7.tinypic.com/5x5zy52.jpg

    im wondering how i could add text into seperate columns while the program is running..i can only get something to be added into column1 but not column2 & 3..if anyone could help that'd be great!
     
  2. Flaming Idiots

    Flaming Idiots Active Member
    Visual Basic Programmers

    Joined:
    Dec 22, 2005
    Posts:
    235
    Referrals:
    1
    Sythe Gold:
    0
    Two Factor Authentication User
    help with ListView please!

    Here is a sub that can do it

    Code:
        Sub AddRow(ByVal ListView As ListView, ByVal ParamArray Columns() As String)
            ListView.Items.Add(New ListViewItem(Columns))
        End Sub
    And here is how to use it:
    Code:
    AddRow(Me.ListView1, "Column1", "Column2", "Column3", "Column4", "...")
    ' You can as many strings as you want.
     
  3. hmm

    hmm Active Member

    Joined:
    Jan 21, 2007
    Posts:
    181
    Referrals:
    2
    Sythe Gold:
    5
    help with ListView please!

    that didnt work too well when in view mode:details.

    also i think that adds columns, i want to be able to add things under the columns...sorry if i confused you

    edit: an example of what i want it to do it like swiftswitchs price lookup for zybez..
     
  4. speljohan

    speljohan Guru
    Visual Basic Programmers

    Joined:
    Apr 24, 2005
    Posts:
    1,450
    Referrals:
    3
    Sythe Gold:
    0
    help with ListView please!

    You mean add rows to it. I just wrote this function, it should work:
    Code:
        Public Sub AddRow(ByVal list As ListView, ByVal ParamArray cols() As String)
            Try
                list.Items.Add(cols(0))
                If Not cols.Length > list.Columns.Count() Then
                    For i As Integer = 1 To cols.Length - 1
                        list.Items(list.Items.Count() - 1).SubItems.Add(cols(i))
                    Next
                Else
                    MsgBox("Error! More values than columns.")
                End If
            Catch ex As Exception
                MsgBox("Error!")
            End Try
        End Sub
    End Sub
     
  5. hmm

    hmm Active Member

    Joined:
    Jan 21, 2007
    Posts:
    181
    Referrals:
    2
    Sythe Gold:
    5
    help with ListView please!

    that is pretty cool, thanks man.
    i tried googling it and everything there seemed so complicated..
     
< puttung together bitmaps | Hello all >


 
 
Adblock breaks this site