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 856941
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T08:19:10+00:00 2026-05-15T08:19:10+00:00

I have a listbox inside a custom control. I use this custom control into

  • 0

I have a listbox inside a custom control. I use this custom control into a form. I would like to be able to get the listbox index changed event when I am working into the form. How can I do that?

  • 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-15T08:19:10+00:00Added an answer on May 15, 2026 at 8:19 am

    This can be a disadvantage of a UserControl. You have to re-publish the events and the properties of one or more of its embedded controls. Consider the alternative: if this UserControl only contains a ListBox then you are much better off simply inheriting from ListBox instead of UserControl.

    Anyhoo, you’ll need to re-fire the SelectedIndexChanged event. And surely you’ll need to be able to let the client code read the currently selected item. Thus:

    public partial class UserControl1 : UserControl {
        public event EventHandler SelectedIndexChanged;
    
        public UserControl1() {
            InitializeComponent();
        }
    
        private void listBox1_SelectedIndexChanged(object sender, EventArgs e) {
            EventHandler handler = SelectedIndexChanged;
            if (handler != null) handler(this, e);
        }
        public object SelectedItem {
            get { return listBox1.SelectedItem; }
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a custom user control extending the Listbox class. Inside of it I
I have a richtextbox and inside I have a listbox. I would like the
So I have this Xaml inside a ListBox Item Template: <ListBox.ItemTemplate> <DataTemplate> <Grid Height=22
I have a Contextmenu with a ListBox inside. Whenever I right click my control
I have a custom user control DatePicker.cs. Inside of another piece of code I
I have a ListBox with RadioButton inside it of the same GroupName. Like so:
I have a MediaElement inside ListBox.How I can get access to audiop_Copy by buttons
i am using a Panorama control. inside each PanoramaItem, i have a ListBox. the
I have a ListBox that has a style defined for ListBoxItems. Inside this style,
Using WPF, I have a ListBox control with a DataTemplate inside it. The relevant

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.