Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

Hi

 

Can any one tell us the way to retrieve the row number in the list view control through a VB.NET application?

 

Thank you

 

Regards

Ananda Saravanan A

Posted

Hi Andy

 

Iam getting error like,

 

'An Unhandled exception of type 'System. ArgumentOutOfRangeException' occurred in system.windows.forms.dll. Additional information: Specified argument was out of the range of valid values'

when I used your syntax.

 

Even though I had two rows with value in the list view.

 

Regards

Anand

  • *Experts*
Posted

I'm guessing you have no selected row so trying to reference row 0 isn't valid. You'll have to check to the number of selected rows bofore using that code.

 

-Nerseus

"I want to stand as close to the edge as I can without going over. Out on the edge you see all the kinds of things you can't see from the center." - Kurt Vonnegut
Posted (edited)

You can use the following code to select the last item enterd.

 

'does the listcontain items??
If Me.ListBox1.Items.Count() > 0 Then
  'If no selection, choose last list item.
  If Me.ListBox1.SelectedIndex = -1 Then
     Me.ListBox1.SelectedIndex = Me.ListBox1.Items.Count() - 1
  End If
End If

 

regards hilmar

Edited by git

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...