Results 1 to 3 of 3

Thread: ListBox & ListBox.Items

  1. #1

    Thread Starter
    New Member
    Join Date
    Dec 2005
    Location
    MALTA
    Posts
    9

    Exclamation ListBox & ListBox.Items

    I have to take info from one form into another and place it itno a listbox sub item. The program is a type of vending machine; each time a product is sold one must decrease from the subitem box. How can i make this work??

    The follow is the function i have till now:

    Public Function DecreaseCoke(ByVal intNum1 As Integer) As String
    Dim intDecrease1 As Integer = Convert.ToInt32(lsbStock.Items(1).SubItems(2))
    Dim intDecrease2 As Integer = intDecrease1 - 1
    lsbStock.Items(1).SubItems(2) = intDecrease2.ToString

  2. #2
    Hyperactive Member
    Join Date
    Sep 2005
    Location
    Alaska
    Posts
    435

    Re: ListBox & ListBox.Items

    I think you mean ListView, since ListBox controls don't have subitems.

    Try this to display information on another form:
    VB Code:
    1. Private Sub ListViewMakeRow(ByVal lvw As ListView, ByVal _
    2.     item_title As String, ByVal ParamArray subitem_titles() _
    3.     As String)
    4.     ' Make the item.
    5.     Dim new_item As ListViewItem = lvw.Items.Add(item_title)
    6.  
    7.     ' Make the sub-items.
    8.     For i As Integer = subitem_titles.GetLowerBound(0) To _
    9.         subitem_titles.GetUpperBound(0)
    10.         new_item.SubItems.Add(subitem_titles(i))
    11.     Next i
    12. End Sub

    Then in your code use this:

    VB Code:
    1. ListViewMakeRow(lvwBooks, _
    2.     ITEM, _
    3.     SUBITEMS, _
    4.     SUBITEMS, SUBITEMS)

    If you are having a problem with the function and not displaying data in the ListView then I don't see an issue.

    If this helped, please add to my rep.

  3. #3

    Thread Starter
    New Member
    Join Date
    Dec 2005
    Location
    MALTA
    Posts
    9

    Re: ListBox & ListBox.Items

    thanks, rep added

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