context menu on form : if no selected items on listview , how to handle the exception, i pass a value from the selecteditem to function
Posted on 2004-09-15
hi , i have a context menu on a listview.
the idea is for the user to right click on the listview , and then when the user clicks on the "Print" item on context menu,
i pass the selected items subitem to a function
but the problem is what to do when there is no item selected.
what i initially did was just have a empty exception but that's not professional and it took much longer when there was an error.
Dim ID As Object
ID = MyListview.SelectedItems(0).SubItems(1).Text
If Not ID Is Nothing Then
Catch ex As Exception
this does not work, immediately from
-->ID = ...
it goes to the error message telling me that "specified argument out of range"