English 中文(简体)
通过使用检查箱从清单中删除项目
原标题:Deleting Items from a Listview through the Use of checkboxes

My program takes a checkboxed item and depending on the serial number that is present on the item on the invoice, subtracts one from the amount list I have the following in a listview on a details page which I added with the following code:

Item - Low Socks(pink)
Serial # - 34-75-860
Price - 5.89
Amount - 12

排在栏目中,而不是上列。

Dim items As New ListViewItem
    items = ListView1.Items.Add("Low Socks(Pink)")
    items.SubItems.Add("34-75-860")
    items.SubItems.Add("$5.89")
    items.SubItems.Add("12")

    items = ListView1.Items.Add("Low Socks(Black)")
    items.SubItems.Add("34-75-900")
    items.SubItems.Add("$5.89")
    items.SubItems.Add("25")

    items = ListView1.Items.Add("Low Socks(Red)")
    items.SubItems.Add("34-75-756")
    items.SubItems.Add("$5.89")
    items.SubItems.Add("10")

    items = ListView1.Items.Add("Low Socks(Orange)")
    items.SubItems.Add("34-75-234")
    items.SubItems.Add("$5.89")
    items.SubItems.Add("34")

    items = ListView1.Items.Add("Low Socks(Blue)")
    items.SubItems.Add("34-75-598")
    items.SubItems.Add("$5.89")
    items.SubItems.Add("23")
End Sub

根据我的发票页,我在发票上的物品旁边有支票箱。 当检查箱被点击时,我想要减少一个。 我稍后将讨论这个问题,并将之改变为它所需要的实际数额,取决于他们订购的那项物品的多少。

Dim item As ListViewItem
    Dim i As Integer
    Dim count As Integer

     count the number of items in itemdetails2 listview
    count = ItemDetails2.ListView1.Items.Count - 1

     loop to read each item in the list
    For i = 1 To count

        If i > count Then Exit For

        item = ItemDetails2.ListView1.Items(i)

         compare the item to the serial number
        If item.Checked = True Then

            If (item.SubItems(0).Text = "34-75-860") Then
                item.SubItems(2).Text -= 1
            End If

            i = i + 1
            count = count - 1
        End If

    Next

    ItemDetails2.Show()
End Sub

Right now it doesn t look like it does anything. I have tried changing my index s on my subitems to 1 and 3 instead of 0 and 2 but i figured because they are subitems that they need to be subitem index 0 and subitem index 2 since there is one item and three subitems to that one item. if that makes sense.... please help.

问题回答

如不把你编成指数,就可以注意到你正在把strings视作数字

item.SubItems(2).Text -= 1

当你尝试:

item.SubItems(2).Text -= CStr(CDec(item.SubItems(2).Text) - 1D)

我希望能帮助......





相关问题
Is Shared ReadOnly lazyloaded?

I was wondering when I write Shared ReadOnly Variable As DataType = New DataType() Or alternatively Shared ReadOnly Variable As New DataType() Is it lazy loaded or as the instance initializes? ...

Entertaining a baby with VB.NET

I would like to write a little application in VB.NET that will detect a baby s cry. How would I get started with such an application?

Choose Enter Rather than Pressing Ok button

I have many fields in the page and the last field is a dropdown with list of values. When I select an item in a dropdown and press Enter, it doesn t do the "Ok". Instead I have to manually click on Ok ...

ALT Key Shortcuts Hidden

I am using VS2008 and creating forms. By default, the underscore of the character in a textbox when using an ampersand is not shown when I run the application. ex. "&Goto Here" is not ...

Set Select command in code

On button Click I want to Set the Select command of a Gridview. I do this and then databind the grid but it doesn t work. What am i doing wrong? protected void bttnView_Click(object sender, ...

Hover tooltip on specific words in rich text box?

I m trying to create something like a tooltip suddenly hoovering over the mouse pointer when specific words in the richt text box is hovered over. How can this be done?

热门标签