dcsimg


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 5 of 5

Thread: Tree view.item ?

  1. #1
    Art Wall Guest

    Tree view.item ?


    I have a listview with checkboxs. How can I prevent the user from only being
    able to check 5 items instead of all items. Any help or direction is appreciated.

    Art Wall

  2. #2
    dnagel Guest

    Re: Tree view.item ?

    One listview (ListView1) on a new form...

    Paste this code ... run it try to check
    more than 5 items...

    D.



    Option Explicit

    Private Sub Form_Load()

    With ListView1.ColumnHeaders
    .Add , , "Author", ListView1.Width / 5
    .Add , , "Author ID", ListView1.Width / 5, lvwColumnCenter
    .Add , , "Birthdate", ListView1.Width / 5
    End With

    With ListView1
    .View = lvwReport
    .Checkboxes = True
    End With

    Dim itmX As ListItem

    Dim i%
    For i = 1 To 10
    Set itmX = ListView1.ListItems.Add(, , "Dennis")
    itmX.SubItems(1) = Int(Rnd(1) * 40000)
    itmX.SubItems(2) = Format(DateAdd("d", Int(Rnd(1) * 6000), Now - 10000), "mm-dd-yyyy")
    Next i

    End Sub


    Private Sub ListView1_ItemCheck(ByVal Item As MSComctlLib.ListItem)
    Dim lstitm As ListItem, c%
    For Each lstitm In ListView1.ListItems
    If lstitm.Checked Then
    c = c + 1
    End If
    Next

    If c > 5 Then Item.Checked = False

    End Sub


    D.

    "Art Wall" <artonthewall@aol.com> wrote in message news:3e8212af$1@tnews.web.devx.com...
    >
    > I have a listview with checkboxs. How can I prevent the user from only being
    > able to check 5 items instead of all items. Any help or direction is appreciated.
    >
    > Art Wall




  3. #3
    PhilipL Guest

    Re: Tree view.item ?


    Thanks for your sample. Do you know if the listview can do the following below.
    I want to only add up the values from the last 3 columns when that row is
    checked only. Basically the user wants to add up only those rows selected.
    Any help or idea is appreciated.

    Date____CompanyName___Computer___Monitor___Printer


    Art Wall




  4. #4
    dnagel Guest

    Re: Tree view.item ?

    'listview with 6 column headers...
    'col 5 (sub item 5) is the SUM

    Place in the ItemCheck Event, after what I already gave you before...

    Dim lstitm As ListItem
    if item.checked then
    itmX.SubItems(5) = itmX.SubItems(2) + itmX.SubItems(3) + itmX.SubItems(4)
    else
    itmX.SubItems(5) = ""
    endif

    D.



    "PhilipL" <aplatfl@aol.com> wrote in message news:3e8346d4$1@tnews.web.devx.com...
    >
    > Thanks for your sample. Do you know if the listview can do the following below.
    > I want to only add up the values from the last 3 columns when that row is
    > checked only. Basically the user wants to add up only those rows selected.
    > Any help or idea is appreciated.
    >
    > Date____CompanyName___Computer___Monitor___Printer
    >
    >
    > Art Wall
    >
    >
    >




  5. #5
    PhilipL Guest

    Re: Tree view.item ?


    > Dim lstitm As ListItem
    > if item.checked then
    > itmX.SubItems(5) = itmX.SubItems(2) + itmX.SubItems(3) + itmX.SubItems(4)
    > else
    > itmX.SubItems(5) = ""
    > endif
    >
    >D.


    Thanks for your example but I need to sum each subitem separately of the
    row checked not the whole row across.


    Art Wall


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center