Results 1 to 10 of 10

Thread: [RESOLVED] key is not unique in collection and some other errors

  1. #1

    Thread Starter
    Enjoy the moment
    Join Date
    Feb 2011
    Location
    Barrio Del pilar madrid spain
    Posts
    5,204

    Resolved [RESOLVED] key is not unique in collection and some other errors

    i am trying to add a icon to my listview based and some example i see but i get all kind of errors
    or sometimes it dosnt even display the first subitem in the listview need some help please
    this is from the example
    Code:
    ListViewIcons.ListItems.Add , , "Settings", 1
    ListViewIcons.Icons.LoadBitmap App.Path & "\Icons\AlphaSettings.bmp", 1, xtpImageNormal
    XtremeSuiteControls.Icons.LoadBitmap App.Path & "\Icons\AlphaSettings.bmp", 1,xtpImageNormal
    this is what i am trying to do
    Code:
            LsVw.ColumnHeaders.Add , , "Customer Name", 1500
            LsVw.ColumnHeaders.Add , , "Address", 1500
    
    Set rs = CN.Execute("SELECT * FROM Customers ORDER BY ID")
               While Not rs.EOf
              Set itm = LsVw.ListItems.Add(1, , rs!FullName)
              itm.Tag = rs!Id
              itm.SubItems(1) = rs!Address
    
    XtremeSuiteControls.Icons.LoadIcon App.Path & "\Icons\AlphaSettings.bmp", 1, xtpImageNormal
    LsVw.Icons.LoadIcon App.Path & "\Icons\AlphaSettings.bmp", 1, xtpImageNormal
    i tried everything dont know what to do to add this icon

    Code:
    Set itm = LsVw.ListItems.Add(, 1, rs!FullName) ' here i get key is not unique in collection
    Set itm = LsVw.ListItems.Add(rs!FullName, , 1) 'here i see in the listview all [1]
    Set itm = LsVw.ListItems.Add(, , rs!FullName, , "1") ' here i get wrong numbers of arguments
    i am lost
    any help will be appreciated
    salsa31

  2. #2
    PowerPoster
    Join Date
    Feb 2006
    Posts
    24,482

    Re: key is not unique in collection and some other errors

    When you use 3rd party controls that almost nobody else has it gets very hard to answer your questions. The proper place would be the 3rd party vendor's support forums.

  3. #3

    Thread Starter
    Enjoy the moment
    Join Date
    Feb 2011
    Location
    Barrio Del pilar madrid spain
    Posts
    5,204

    Re: key is not unique in collection and some other errors

    is the e.x in post #1 first code dosnt help?
    there vendor's support takes ages

  4. #4
    PowerPoster
    Join Date
    Feb 2012
    Location
    West Virginia
    Posts
    14,205

    Re: key is not unique in collection and some other errors

    The example seems rather odd. You add the item first then add the icon to the list and then add it to the control suite [whatever that is] seems backwards to me.
    For a normal list view you would use an image list, add the images/icons to that first and then when you add an item to the list you specify the index of the image that you want to add.

    This is a problem with 3rd party controls. Hard for people to help if they don't use the same control. I generally try to avoid them when ever possible with the exception of Active Reports which I use in every project that needs reporting.

  5. #5

    Thread Starter
    Enjoy the moment
    Join Date
    Feb 2011
    Location
    Barrio Del pilar madrid spain
    Posts
    5,204

    Re: key is not unique in collection and some other errors

    i know sir
    the normal listview is easy to add and its free
    i paid money for this active x control, and to understand the logic sometimes not easy
    i know you are very experienced with programming
    maybe you can try to give me a advice or a sample of your logic
    how to accomplish this?
    any thing will be find

  6. #6

    Thread Starter
    Enjoy the moment
    Join Date
    Feb 2011
    Location
    Barrio Del pilar madrid spain
    Posts
    5,204

    Re: key is not unique in collection and some other errors

    BTW what is key is not unique in collection?

  7. #7
    PowerPoster
    Join Date
    Aug 2010
    Location
    Canada
    Posts
    2,443

    Re: key is not unique in collection and some other errors

    The ListView takes four parameters: Index, Key, Text, and IconID (in that order).

    If 1 is your icon ID, and rs!FullName is your text, then you should call it like this:

    Code:
    Set itm = LsVw.ListItems.Add(, , rs!FullName, 1)

  8. #8
    PowerPoster
    Join Date
    Aug 2010
    Location
    Canada
    Posts
    2,443

    Re: key is not unique in collection and some other errors

    RE: key is not unique in collection

    You were trying to set the Key parameter to 1 more than once, hence the error. Keys must be unique (that is, not repeated for multiple items - 1 key=1 item) so that you can reference a single item by it's key.

  9. #9

    Thread Starter
    Enjoy the moment
    Join Date
    Feb 2011
    Location
    Barrio Del pilar madrid spain
    Posts
    5,204

    Re: key is not unique in collection and some other errors

    tnx jpbro i tried you method dosnt display nothing
    ill send them agin a email for thie issue

  10. #10
    PowerPoster
    Join Date
    Feb 2012
    Location
    West Virginia
    Posts
    14,205

    Re: [RESOLVED] key is not unique in collection and some other errors

    Based on the sample this line
    Code:
    Set itm = LsVw.ListItems.Add(1, , rs!FullName)
    Should be
    Code:
    Set itm = LsVw.ListItems.Add(, , rs!FullName,1)
    also this line
    Code:
    LsVw.Icons.LoadIcon App.Path & "\Icons\AlphaSettings.bmp", 1, xtpImageNormal
    In the example uses LoadBitmap rather than load icon and it is a bmp that you are loading so you might want to do it like it is in the example.
    Last edited by DataMiser; Apr 30th, 2014 at 12:53 AM.

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