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

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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T04:15:45+00:00 2026-06-06T04:15:45+00:00

Is there some event I can use to tell when the SelectedIndices property changes

  • 0

Is there some event I can use to tell when the SelectedIndices property changes for a listbox? I want to deselect items in a listbox based on a certain property value of the item. I’ve hooked up an event that works for when a SelectedIndex is changed, but not sure how to do it for when the SelectedIndices property changes for multiselection.

private void listBox1_SelectedIndexChanged(object sender, EventArgs e)
{
     Curve curItem = (Curve)listBox1.SelectedItem;
     int index = listBox1.Items.IndexOf(curItem);

     if (curItem.newName == null)
     {
          listBox1.SetSelected(index, false);
     }
}
  • 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-06-06T04:15:47+00:00Added an answer on June 6, 2026 at 4:15 am

    According to MSDN, this event will be fired every time the selection changes:

    If the SelectionMode property is set to SelectionMode.MultiSimple or SelectionMode.MultiExtended, any change to the SelectedIndices collection, including removing an item from the selection, will raise this event.

    So basically, you can use it the same way as using it with single selection.

    Sample:

    For example if you want to deselect all items with null as newName:

    foreach (var item in listBox1.SelectedItems)
    {
        if ((item as Curve).newName == null)
        {
            int index = listBox1.SelectedItems.IndexOf(item);
            listBox1.SetSelected(index, false);
        }
    }
    

    (I’m not sure if you can deselect items inside a foreach loop since it changes the SelectedItems object itself. If it does not work, you can still make a temporary list of those items and deselect them after the loop.)

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

Sidebar

Related Questions

There are some events that I can use for handling drag & drop: https://developer.mozilla.org/en/DragDrop/Drag_and_Drop
Is there an event that I can tap into in Global.asax to execute some
There are some event listeners like mouseover, mouseout and click to use on the
I want to interrupt some specific grails domain class events(read,write,delete,update).Is there any hibernate eventlistner
for some purpose i want to cache the Window.Event object in a variable and
is there some way to force the gridview's pager to show up, even when
My application server needs to notify users about some events via email. Usually there
There are some restricted characters (and even full filenames, in Windows), for file and
I have some trouble with jquery ui-events: In my application, there are some sliders.
I wonder if there's some way of doing this, or even if it should

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.