title: Is there an easier way to do this?
body: <p>I am looping through a listbox, and I need to get the same value you would get if you did .selectvalue, but without selecting the row. This is how I am doing it now, and it seems dumb.</p>
  
  <pre><code>    For intCtr = 0 To lstUserRoleAll.Items.Count -1 
          lstUserRoleAll.SelectedIndex = intCtr
          InsertUserRoles(lstUserRoleAll.SelectedValue)
      Next
  </code></pre>
  
  <p>I have read that <code>lstUserRoleAll.Items(intCtr).value</code> should work, but value isn't a member of that. Also, <code>lstUserRoleAll.Items(intCtr).tostring</code> gets me the text "System.Data.DataRowView".</p>
  
  <p>Surely there is a better way to do this.</p>
  
  <p><a href="https://i.stack.imgur.com/ta8Z7.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/ta8Z7.png" alt="enter image description here"></a></p>
  
  <p>Here is the code that I use to add the rows:</p>
  
  <pre><code>        Dim rsSelectedGroups As DataTable
          strSQL = "SELECT UID, Name "
          [Rest of query]
          rsSelectedGroups = DataAccess.GetDataTable(strSQL)
          lstUserRoleCurrent.DataSource = rsSelectedGroups
          lstUserRoleCurrent.ValueMember = "UID"
          lstUserRoleCurrent.DisplayMember = "Name"
  </code></pre>