Results 1 to 16 of 16

Thread: Is there a better way??

  1. #1

    Thread Starter
    Fanatic Member steve65's Avatar
    Join Date
    Jun 2000
    Posts
    610

    Is there a better way??

    Hi All,

    I would like to have your input again to make sure I am coding things optionally.

    1. When you know the key to an image in an imagelist is there a better way to add the image to a listview besides what I am already doing?
    Code:
    Set TempListItem = lvwObjects.ListItems.Add(, , ObjectsFound(i).Name)
    For j = 1 To ImageList.ListImages.Count
        If ImageList.ListImages(j).Key = ObjectsFound(i).ContentType Then
            lvwObjects.SmallIcons = ImageList
            TempListItem.SmallIcon = j
            ImageFoundFlag = True
        End If
    Next jNext j
    2. Is there a way to add two icons next to each other in a listview in report mode?

    3. Is there a way to convert a 1 or a 0 to true or false in one line for a check box?
    Code:
        If Check1.Value = 0 Then
            ListObjects1.ShowLockOwner = False
        Else
            ListObjects1.ShowLockOwner = True
        End If
    Again thanks all for your input!!
    This space for rent...

  2. #2
    For number 3: CBool(-(checkboxname.Value))

  3. #3

    Thread Starter
    Fanatic Member steve65's Avatar
    Join Date
    Jun 2000
    Posts
    610
    Thank you. When your a lone programmer sometimes you miss the easy stuff.
    This space for rent...

  4. #4
    Originally posted by filburt1
    For number 3: CBool(-(checkboxname.Value))
    BTW, you'd use it like this:

    VB Code:
    1. If CBool(-([[i]checkboxname[/i].Value)) ' If true
    2.     Msgbox "Checked"
    3. Else ' False
    4.     Msgbox "Not checked"
    5. End If

  5. #5

    Thread Starter
    Fanatic Member steve65's Avatar
    Join Date
    Jun 2000
    Posts
    610
    Courious why the minus sign?
    CBool(-(checkboxname.Value))

    Because this seems to work.
    Code:
    ListObjects1.ShowLockOwner = CBool(Check1.Value)
    Originally posted by filburt1
    For number 3: CBool(-(checkboxname.Value))
    This space for rent...

  6. #6
    VB is different from all other language in that -1 is True, instead of 1.

  7. #7

    Thread Starter
    Fanatic Member steve65's Avatar
    Join Date
    Jun 2000
    Posts
    610
    If I use 1 or -1 in CBOL I get TRUE. No big deal just interesting.
    This space for rent...

  8. #8
    I'm about to be a PowerPoster! Joacim Andersson's Avatar
    Join Date
    Jan 1999
    Location
    Sweden
    Posts
    14,649
    1.
    VB Code:
    1. On Error Resume Next
    2. Set TempListItem = lvwObjects.ListItems.Add(, , ObjectsFound(i).Name)
    3. TempListItem.SmallIcon = ImageList.ListImages(ObjectsFound(i).ContentType).Index
    4. If Err = 0 Then
    5.     ImageFoundFlag = True
    6. End If
    Best regards

  9. #9

    Thread Starter
    Fanatic Member steve65's Avatar
    Join Date
    Jun 2000
    Posts
    610
    Thanks Joacim.

    Let me reword question 2 then. If I can't add a second icon to a list view, can I add an icon to a column?
    This space for rent...

  10. #10
    I'm about to be a PowerPoster! Joacim Andersson's Avatar
    Join Date
    Jan 1999
    Location
    Sweden
    Posts
    14,649
    ListSubItems can have icons if you use VB6.

  11. #11

    Thread Starter
    Fanatic Member steve65's Avatar
    Join Date
    Jun 2000
    Posts
    610
    Joacim,

    Man thank you very much!!

    You all are helping me to make one cool listview component!

    I know this has been asked before but....

    besides hooking the the listview is there a way to detect the resize of a column?

    Originally posted by Joacim Andersson
    ListSubItems can have icons if you use VB6.
    This space for rent...

  12. #12
    Frenzied Member nishantp's Avatar
    Join Date
    Jan 2001
    Location
    Where you least expect me to be
    Posts
    1,375
    BTW, for #3, VB makes that 1, -1 distinction automatically. You dont need to do CBool. Just do:
    VB Code:
    1. If Check1.Value Then
    2.     MsgBox "checked"
    3. Else
    4.     MsgBox "unckecked"
    5. End If
    Or even better, because of VBs default properties, this works to:
    VB Code:
    1. If Check1 Then
    2.     MsgBox "checked"
    3. Else
    4.     MsgBox "unckecked"
    5. End If
    You just proved that sig advertisements work.

  13. #13
    The checkbox has three values! Checked, unchecked, and grayed (sorta checked). So does If check for a non-zero as true? If that's the case, then grayed will be treated as checked.

  14. #14
    Frenzied Member nishantp's Avatar
    Join Date
    Jan 2001
    Location
    Where you least expect me to be
    Posts
    1,375
    damn...
    You just proved that sig advertisements work.

  15. #15
    Yeah, well...

  16. #16
    Registered User Nucleus's Avatar
    Join Date
    Apr 2001
    Location
    So that's what you are up to ;)
    Posts
    2,530
    3.
    VB Code:
    1. ListObjects1.ShowLockOwner = Check1

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