[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Listview Add, Remove, Edit Sub Items

Posted on 2006-05-26
3
Medium Priority
?
337 Views
Last Modified: 2008-02-01
Username       Age      Hair Color
----------------------------------------
Jack               20        Black
Jane               28        Brown

ListView1.Items.Add("jack")
ListView1.Items("jack").subitem("age").text = "20"
ListView1.Items("jack").subitem("hair color").text = "Black"
ListView1.Items.Remove("jack")

ListView1.Items.Add("jessica")
ListView1.Items("jessica").subitem("age").text = "28"
ListView1.Items("jessica").subitem("hair color").text = "Brown"
ListView1.Items.Remove("jessica")

How can I use the listview item above for basic functionality?  This control seems so difficult to use. Can you translate the code into the proper use? I know i'm not using these items correctly. Please Help
0
Comment
Question by:Hepen
3 Comments
 
LVL 9

Accepted Solution

by:
jrscherer earned 1000 total points
ID: 16774243
Hi Hepen,

The ListView Control consistes of a collection lf ListViewItem, and each ListViewItem consist of SubItems. first, Items and subitems must be instantiated before they can be used. This are regular objects. Then, you address all of them by the index and not by content. Below see an example. It is a copy of the integrated help of the ListViewItem class.
It is always a good idea to consult the integrated help (F1). It shows the fundamentals of how to program a ListView

Private Sub CreateMyListView()
    ' Create a new ListView control.
    Dim listView1 As New ListView()
    listView1.Bounds = New Rectangle(New Point(10, 10), New Size(300, 200))

    ' Set the view to show details.
    listView1.View = View.Details
    ' Allow the user to edit item text.
    listView1.LabelEdit = True
    ' Allow the user to rearrange columns.
    listView1.AllowColumnReorder = True
    ' Display check boxes.
    listView1.CheckBoxes = True
    ' Select the item and subitems when selection is made.
    listView1.FullRowSelect = True
    ' Display grid lines.
    listView1.GridLines = True
    ' Sort the items in the list in ascending order.
    listView1.Sorting = SortOrder.Ascending

    ' Create three items and three sets of subitems for each item.
    Dim item1 As New ListViewItem("item1", 0)
    ' Place a check mark next to the item.
    item1.Checked = True
    item1.SubItems.Add("1")
    item1.SubItems.Add("2")
    item1.SubItems.Add("3")
    Dim item2 As New ListViewItem("item2", 1)
    item2.SubItems.Add("4")
    item2.SubItems.Add("5")
    item2.SubItems.Add("6")
    Dim item3 As New ListViewItem("item3", 0)
    ' Place a check mark next to the item.
    item3.Checked = True
    item3.SubItems.Add("7")
    item3.SubItems.Add("8")
    item3.SubItems.Add("9")

    ' Create columns for the items and subitems.
    listView1.Columns.Add("Item Column", -2, HorizontalAlignment.Left)
    listView1.Columns.Add("Column 2", -2, HorizontalAlignment.Left)
    listView1.Columns.Add("Column 3", -2, HorizontalAlignment.Left)
    listView1.Columns.Add("Column 4", -2, HorizontalAlignment.Center)

    'Add the items to the ListView.
    listView1.Items.AddRange(New ListViewItem() {item1, item2, item3})

    ' Create two ImageList objects.
    Dim imageListSmall As New ImageList()
    Dim imageListLarge As New ImageList()

    ' Initialize the ImageList objects with bitmaps.
    imageListSmall.Images.Add(Bitmap.FromFile("C:\MySmallImage1.bmp"))
    imageListSmall.Images.Add(Bitmap.FromFile("C:\MySmallImage2.bmp"))
    imageListLarge.Images.Add(Bitmap.FromFile("C:\MyLargeImage1.bmp"))
    imageListLarge.Images.Add(Bitmap.FromFile("C:\MyLargeImage2.bmp"))

    'Assign the ImageList objects to the ListView.
    listView1.LargeImageList = imageListLarge
    listView1.SmallImageList = imageListSmall

    ' Add the ListView to the control collection.
    Me.Controls.Add(listView1)
End Sub 'CreateMyListView


0
 

Author Comment

by:Hepen
ID: 16776265
oh my god your kidding me.

is there any other form control that will give me the above functionality or similar that i was looking for? I'm not looking to code a C++ application. LOL
0
 
LVL 3

Expert Comment

by:GilesBathgate
ID: 16779729
DataGrid?

There are hundreds of third party grid/listview controls on the web Try Xceed .Grid control
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If you're writing a .NET application to connect to an Access .mdb database and use pre-existing queries that require parameters, you've come to the right place! Let's say the pre-existing query(qryCust) in Access takes a Date as a parameter and l…
Creating an analog clock UserControl seems fairly straight forward.  It is, after all, essentially just a circle with several lines in it!  Two common approaches for rendering an analog clock typically involve either manually calculating points with…
In a question here at Experts Exchange (https://www.experts-exchange.com/questions/29062564/Adobe-acrobat-reader-DC.html), a member asked how to create a signature in Adobe Acrobat Reader DC (the free Reader product, not the paid, full Acrobat produ…
Look below the covers at a subform control , and the form that is inside it. Explore properties and see how easy it is to aggregate, get statistics, and synchronize results for your data. A Microsoft Access subform is used to show relevant calcul…
Suggested Courses
Course of the Month20 days, left to enroll

873 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question