dcsimg
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3

Thread: [RESOLVED] Run-time Error: 380 - Invalid property value.

Hybrid View

  1. #1
    Join Date
    Jul 2007
    Posts
    51

    [RESOLVED] Run-time Error: 380 - Invalid property value.

    Good morning everybody:

    I am attempting to populate a listview control on Form Load()
    and I get a Run-Time Error: 380 - Invalid property value. Below is the line that generated the error:

    Code:
    lvw.ListItems(lvw.ListItems.Count).SubItems(1) = OutlookAddressEntry.Address
    Below is also my entire FormLoad module:

    Code:
    Private Sub Form_Load()
    Set OutlookApp = New Outlook.Application
    Set OutlookMailItem = OutlookApp.CreateItem(olMailItem)
    Set OutlookNameSpace = OutlookApp.GetNamespace("MAPI")
    
    lvw.ListItems.Clear
    
    For Each OutlookAddressList In OutlookNameSpace.AddressLists
        For Each OutlookAddressEntry In OutlookAddressList.AddressEntries
            lvw.ListItems.Add , , OutlookAddressEntry.Name
            lvw.ListItems(lvw.ListItems.Count).SubItems(1) = OutlookAddressEntry.Address
            lvw.ListItems(lvw.ListItems.Count).SubItems(2) = OutlookAddressEntry.ID
            lvw.ListItems(lvw.ListItems.Count).Tag = OutlookAddressEntry.ID
        Next
    Next
    End Sub
    Any help will b greatly appreciated
    Thanks,
    GiftX

  2. #2
    Join Date
    Jul 2006
    Location
    Germany
    Posts
    3,725

    Re: Run-time Error: 380 - Invalid property value.

    This error comes up if you havent created columns in your ListView control.
    The .SubItems() property is available only if you have more than one column created at design time. You also can add columns at runtime, but you must not access .SubItem() unless you have created them.

    If you want to create ColumnHeaders at runtime, you'd use
    Code:
      ListView1.ColumnHeaders.add , , "Headertext"
    The number of items in your ColumnHeaders collection determines the number of .SubItems() properties available to a ListItem.

  3. #3
    Join Date
    Jul 2006
    Location
    Germany
    Posts
    3,725

    Re: Run-time Error: 380 - Invalid property value.

    To be more specific to your sample code:

    Code:
    Private Sub Form_Load()
    Set OutlookApp = New Outlook.Application
    Set OutlookMailItem = OutlookApp.CreateItem(olMailItem)
    Set OutlookNameSpace = OutlookApp.GetNamespace("MAPI")
    
    lvw.ListItems.Clear
    
    'create columns
    lvw.ColumnHeaders.Clear
    lvw.ColumnHeaders.Add , ,"Address"
    lvw.ColumnHeaders.Add , ,"ID"
    'now .SubItems(1) and .SubItems(2) are available to fill in.
    
    
    For Each OutlookAddressList In OutlookNameSpace.AddressLists
        For Each OutlookAddressEntry In OutlookAddressList.AddressEntries
            lvw.ListItems.Add , , OutlookAddressEntry.Name
            lvw.ListItems(lvw.ListItems.Count).SubItems(1) = OutlookAddressEntry.Address
            lvw.ListItems(lvw.ListItems.Count).SubItems(2) = OutlookAddressEntry.ID
            lvw.ListItems(lvw.ListItems.Count).Tag = OutlookAddressEntry.ID
        Next
    Next
    End Sub

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Windows Mobile Development Center


Click Here to Expand Forum to Full Width




On-Demand Webinars (sponsored)