Results 1 to 2 of 2

Thread: [2005] Listview Selected Item

  1. #1

    Thread Starter
    Member
    Join Date
    Feb 2008
    Posts
    55

    [2005] Listview Selected Item

    Hello,

    I have a listview on my form which is filled from a dataset.
    One of my rows is 'Modified By' which is populated if the record has been changed, but is blank otherwise.

    I want to capture the information from this 'Modified By' field, but am having problems if the field is blank.

    Basically my code is
    Code:
    If Listview1.SelectedItems(0).SubItems(3).Text = 'ABCDEFG' then
    do stuff ...........
    This works fine if the field has data in it, but if it is blank then I get an error saying :

    "InvalidArgument=Value of '3' is not valid for 'index'.
    Parameter name: index"

    Can I get round this ?

    Thanks in advance.

  2. #2
    Frenzied Member bmahler's Avatar
    Join Date
    Oct 2005
    Location
    Somewhere just west of the Atlantic
    Posts
    1,568

    Re: [2005] Listview Selected Item

    put a check around that if checking the count of the subitems to make sure that there is an an item at that index.
    Obviously you can modify this as needed but this will check to make sure ther are at least 4 subitems.
    Code:
    If Listview1.SelectedITems(0).SubItems.Count > 3 Then
        'Add yor function in here
    End If
    Boooya
    • Visual Studio 2008 Professional
    • Don't forget to use [CODE]your code here[/CODE] when posting code
    • Don't forget to rate helpful posts!
    • If you're question was answered please mark your thread [Resolved]


    Code Contributions:
    PHP
    PHP Image Gallery v1.0PHP Image Gallery v2.0
    VB 2005
    Find Computers on a networkSimple License EncryptionSQL Server Database Access dllUse Reflection to Return Crystal ReportDocumentSilently Print PDFGeneric Xml Serailizer


    Useful Links: (more to come)
    MSDN (The first and foremost)MSDN Design Guidelines API Reference • Inno Setup CompilerInno Setup PreprocessorISTool - Fairly easy to use GUI for creating inno setup projects • Connection StringsNAnt -Automated BuildsCruise Control .NET - Frontend for automated builds

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