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

  • Home
  • SEARCH
  • 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 3406816
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T05:40:28+00:00 2026-05-18T05:40:28+00:00

I have a listview and a button next to it that uses the selected

  • 0

I have a listview and a button next to it that uses the selected item to do an action. If the user doesn’t make a selection, but clicks on the button they are told to make a selection first.

What I have below works, but is there a way where the calling method doesn’t have to have the “if(not selected)” return statement? I want to just call “selectionFound()” method from other events that rely on the listview? I’d like the selectionFound method to exit out of not just itself, but also the calling method and return control back to the user. So instead of return true/false as below, I’d like to have just return or whatever keyword.

private void deleteData()
{
 // if nothing selected, warn user and return control
 if(!selectionFound()) return;
        .....
}

private bool selectionFound()
{
 // make sure user selected an item from listview, warn and exit if not
 if (lvwInventory.SelectedIndex == -1)
 {
  MessageBox.Show("Please select an item first");
  return false;
 }
 else
  return true;
}
  • 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-18T05:40:29+00:00Added an answer on May 18, 2026 at 5:40 am

    Aside from returning a flag as per your example, the closest you’re going to get is to throw an exception, as that’s the only mechanism I’m aware of that can jump entire stack frames without letting methods finish executing.

    EDIT: And you should not use exceptions for this purpose, since they indicate that something exceptional happened.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have managed to setup a page so that a user clicks an item
I have a ListView that displays a link button. I need the link button
I have an android listview filled with items. Every item has a button. This
I have to update a ListView item by clicking on a button. How do
I have listview control.There is an option to remove selected items.After the user removes
I am implementing a listview, and a button next to it. I have to
I have a class with a ListView . Once the user makes a selection
I have a ListView that uses a custom layout that has 5 child View
I have a custom ListView with two button and I when I click either
I have a listView, where each row has a button in the row layout.

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.