Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 729351
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T06:47:14+00:00 2026-05-14T06:47:14+00:00

I have a ListView control set up in details mode with 5 columns. It

  • 0

I have a ListView control set up in details mode with 5 columns. It is populated by code using the following subroutine:

            For j = 0 To 14
                cmd = New OleDbCommand("SELECT TeacherName, ClassSubject, BookingDate, BookingPeriod FROM " & SchemaTable.Rows(i)!TABLE_NAME.ToString() & " WHERE (((BookingDate)=" & Chr(34) & Date.Today.AddDays(j) & Chr(34) & ") AND ((UserName)=" & Chr(34) & user & Chr(34) & "));", cn)
                dr = cmd.ExecuteReader
                Dim itm As ListViewItem
                Dim itms(4) As String
                While dr.Read()
                    itms(0) = dr(0)
                    itms(1) = SchemaTable.Rows(i)!TABLE_NAME.ToString()
                    itms(2) = dr(1)
                    itms(3) = dr(2)
                    itms(4) = dr(3)
                    itm = New ListViewItem(itms)
                    Manage.ManageList.Items.Add(itm)
                End While
            Next

Note that this is not the full routine, just the bit that populated the grid.

Now I need to retrieve data from the ListView control in order to delete a booking in my database. I used the following code to retrieve the content of each column:

ManageList.SelectedItems(0).Text

But it only seems to work on index 0. If I do:

ManageList.SelectedItems(3).Text

I get this error:

InvalidArgument=Value of ‘3’ is not
valid for ‘index’. Parameter name:
index

I’m pretty much stumped, it seems logical to me that index 1 will point to the 2nd column, index 2 to the 3rd etc, as it’s 0 based?

Any help would be appreciated, thanks.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-14T06:47:14+00:00Added an answer on May 14, 2026 at 6:47 am

    When you say ManageList.SelectedItems(3).Text, you’re asking it for the forth item selected in your list, not the forth column of the item selected.

    See MSDN

    EDIT: Think of it this way: ManageList.SelectedItems(0)=itms, which is a string array. The following example shows how you can access the forth array value of the selected array in the list:

    Dim itms() As String = ManageList.SelectedItems(0)
    If itms.Length>3 Then
        itms(3).DoWhatever
    End If
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a ListView control that is in FullRowSelect mode, MultiSelect off and using
I have a ListView control on my form set up like this in details
Can you have a multicolumn listview control where one of the columns is a
I've got a ListView control in Details mode with a single column. It's on
I have a windows form with a listview control. I set the MultiSelect property
I have an ExtJS ListView control with 4 columns. One of the columns contain
I have a WPF ListView control for which I am dynamically creating columns. One
I have a ListView control in Asp.Net WebForms which display a set of elements,
I have a ListView control, and I'm trying to figure out the easiest/best way
I can set the ToolTip property of a ListView control, but that's for the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.