Results 1 to 3 of 3

Thread: [RESOLVED] VS2015 is this the correct way to check is listview is selected?

  1. #1

    Thread Starter
    Enjoy the moment
    Join Date
    Feb 2011
    Location
    Barrio Del pilar madrid spain
    Posts
    5,137

    Resolved [RESOLVED] VS2015 is this the correct way to check is listview is selected?

    Code:
    If IsNothing(lsvw.FocusedItem) Then

  2. #2
    .NUT jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    105,040

    Re: VS2015 is this the correct way to check is listview is selected?

    It depends what you mean by "selected". The ListView has a SelectedItems property and a FocusedItem property so it should be fairly obvious that, officially, the FocusedItem has nothing to do with selection. The focused item may or may not be selected. Normally you would test the Count of the SelectedItems and, if it is zero, no items are selected.

    By the way, don't use that IsNothing function in VB.NET. If you want to know whether a reference is Nothing then you compare it to Nothing, e.g.
    vb.net Code:
    1. If lsvw.FocusedItem Is Nothing Then
    The Is operator is how you always compare for reference equality. Just as you have '=' and '<>' for value equality and inequality, you have Is and IsNot for reference equality and inequality.

  3. #3

    Thread Starter
    Enjoy the moment
    Join Date
    Feb 2011
    Location
    Barrio Del pilar madrid spain
    Posts
    5,137

    Re: VS2015 is this the correct way to check is listview is selected?

    thank you

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